SQL query to get the employee name and their manager name from the same table
You can self-join the table to get the manager’s name from his ID:
You can self-join the table to get the manager’s name from his ID:
Open and edit /etc/my.cnf or /etc/mysql/my.cnf, depending on your distribution. Add skip-grant-tables under [mysqld] Restart MySQL You should be able to log in to MySQL now using the below command mysql -u root -p Run mysql> flush privileges; Set new password by ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘NewPassword’; Go back to /etc/my.cnf and remove/comment skip-grant-tables Restart MySQL Now you will be able to login with the … Read more
Oracle does not allow joining tables in an UPDATE statement. You need to rewrite your statement with a co-related sub-select Something like this: For a complete description on the (valid) syntax of the UPDATE statement, please read the manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10008.htm#i2067715
Works fine for me in 5.0.27 I just get a warning (not an error) that the table exists;
Can anyone give me a good example of when CROSS APPLY makes a difference in those cases where INNER JOIN will work as well? See the article in my blog for detailed performance comparison: INNER JOIN vs. CROSS APPLY CROSS APPLY works better on things that have no simple JOIN condition. This one selects 3 … Read more
There are many formats supported by SQL Server – see the MSDN Books Online on CAST and CONVERT. Most of those formats are dependent on what settings you have – therefore, these settings might work some times – and sometimes not. The way to solve this is to use the (slightly adapted) ISO-8601 date format that is supported by SQL … Read more
Rather slow, but working method to include any of words: If you need all words to be present, use this: If you want something faster, you need to look into full text search, and this is very specific for each database type.
Your subquery is selecting two columns, while you are using it to project one column (as part of the outer SELECT clause). You can only select one column from such a query in this context. Consider joining to the users table instead; this will give you more flexibility when selecting what columns you want from … Read more
Reading this original article on The Code Project will help you a lot: Visual Representation of SQL Joins. Also check this post: SQL SERVER – Better Performance – LEFT JOIN or NOT IN?. Find original one at: Difference between JOIN and OUTER JOIN in MySQL.