SQL is a powerful tool in your toolbox and has numerous dialects and possible use cases. So it would be a long journey to learn “all” of it. However, since you are reading this, you most likely have a purpose in your mind and it will reduce the required time significantly.
To use on a project
If you need to learn SQL to use an Database Management System for a project and if you don’t have a strict performance limitations, learning the very basics of SQL should probably be sufficient for you. You will need to learn both DDL (Data Definition Language) and DML (Data Manipulation Language) parts of the language to declare the tables to store your data and perform some basic queries to insert and retrieve the data. In that case, there are hundreds of free courses and tutorials on Internet that mostly claim you can learn it as little as 3 hours. Even though it is perfectly doable, you will probably need a little bit more time to use it with your language of choice. In our opinion, you will need around 1 week to overcome all the unexpected errors and hiccups that will happen on the road.
If you have some kind of concerns about the performance or the neatness of your solution, you will also need to basics of Database Design. Learning to structure your data and refine your tables to perform the operations faster without loosing any data is not very hard learn. Yet, getting the grasp of it may take about 1 month.
As you can see, learning SQL sufficient enough is not that hard, but you should do some research about the platform you will use, the programming language, Database Management System before committing your time on it. You can also consider using one of the Object Relational Mapping (ORM) solutions for your language to skip learning SQL altogether.
For data analysis
If you are going to use SQL to analyze collected data things to learn will be quite different. Basic queries probably won’t be sufficient for you. You will need to perform lots of filterings, groupings and yes, the infamous joins. Even though some people will say that SQL is not the best tool for this job, it is powerful enough and you can squeeze lots of insights from your data.
You will need to learn the idea behind the Database Design in order to follow the structure of the data, but this will require much less time than performing the design yourself. Yet, the time you save on this area will be spend on the querying part. Because you will need to write more complex queries may be using much less used functionalities of the language. All in all, we believe that you may learn to use SQL sufficient enough in 1 month.