Having XAMPP installed when i try to type mysql in my windows command prompt it would give me the following error:
'mysql' is not recognized as an internal or external command, operable program or batch file.
This simply means that the ‘mysql’ excutable command file (mysql.exe) was not added to your system path therefore the system was unable to locate this file. To add the ‘mysql’ to system path try to locate the ‘mysql’ resident folder. In my case (Windows7) it was
Copy it (to clipboard) and go to Control Panel -> System and Security -> System and paste the copied folder path into Variable value: field of Edit System Variable pop up. Prefix it with a semi-colon (;) to separate it from other existing values (see image below – click to open larger image)
FIND_IN_SET is the function which return result in searching for specific values in a comma separated values in a table column ,
You don’t need to use large set of record and array to filter those records , use the query below to get records which you needed,
SELECT * FROM Table_name WHERE FIND_IN_SET(‘value’, column_name)
Have a look on the table columns i have web_class_id in a commas separated values , i want to retrieve web_class_id with value 63 now i will use the query below
SELECT * FROM Table_name WHERE FIND_IN_SET(’63’, web_class_id)
I got the result below
Consider the employee table with the fields emp_id and salary.
Now if you want get the 1st highest salary then you can use the below query
SELECT DISTINCT `salary` FROM `employee`ORDER BY `salary` DESC LIMIT 0, 1
To find the 2nd highest salary then you can use the following query
SELECT DISTINCT `salary` FROM `employee`ORDER BY `salary` DESC LIMIT 1, 1
Likewise you can find the any of the highest salary using the above query by changing the LIMIT value
Also you can find the highest salary in many other ways but this one of the easy way to find the highest salary.
Note: This is the most common question asked in many of the interviews