how to join all three query results to one in mysql
-
hi i have written 3 different select query in mysql based on yesterday,today, tommorow dates to get the birthday details as follows select concat(name,', ',title) as 'Yesterday 30-04-2014' from personal_details where DOB=curdate() - interval 1 day select concat(name,', ',title) as 'Today 01-05-2014' from personal_details where DOB=DATE(NOW()) select concat(name,', ',title) as 'Tommorow 02-05-2014' from personal_details where DOB=curdate() + interval 1 day how to join all 3 query results to one, i need to show as below Yesterday Today Tomorrow aaaa gggg nnnnn bbbb hhhhh mmmm dddd jjjjj eeee ffff How to achieve this, i am not able to do. If i tried with join there it wont match any condition and will not work because in each query result i will get unique values. I tried with another query by putting as below select a.* from (select CASE DOB WHEN (curdate() - interval 1 day) THEN concat(name,', ',title) ELSE '' END AS 'Yesterday', CASE DOB WHEN (DATE(NOW())) THEN concat(name,', ',title) ELSE '' END AS 'Today',CASE DOB WHEN (curdate() + interval 1 day) THEN concat(name,', ',title) ELSE '' END AS 'Tomorrow' from personal_details ) as a where a.Yesterday IS NOT NULL and a.Today IS NOT NULL and a.Tomorrow IS NOT NULL It is showing the result like in all the three column some rows will be null I dont want null values in any column. i want output as above. How to achieve this. If anybody knows please reply me. Thanks in advance.
-
hi i have written 3 different select query in mysql based on yesterday,today, tommorow dates to get the birthday details as follows select concat(name,', ',title) as 'Yesterday 30-04-2014' from personal_details where DOB=curdate() - interval 1 day select concat(name,', ',title) as 'Today 01-05-2014' from personal_details where DOB=DATE(NOW()) select concat(name,', ',title) as 'Tommorow 02-05-2014' from personal_details where DOB=curdate() + interval 1 day how to join all 3 query results to one, i need to show as below Yesterday Today Tomorrow aaaa gggg nnnnn bbbb hhhhh mmmm dddd jjjjj eeee ffff How to achieve this, i am not able to do. If i tried with join there it wont match any condition and will not work because in each query result i will get unique values. I tried with another query by putting as below select a.* from (select CASE DOB WHEN (curdate() - interval 1 day) THEN concat(name,', ',title) ELSE '' END AS 'Yesterday', CASE DOB WHEN (DATE(NOW())) THEN concat(name,', ',title) ELSE '' END AS 'Today',CASE DOB WHEN (curdate() + interval 1 day) THEN concat(name,', ',title) ELSE '' END AS 'Tomorrow' from personal_details ) as a where a.Yesterday IS NOT NULL and a.Today IS NOT NULL and a.Tomorrow IS NOT NULL It is showing the result like in all the three column some rows will be null I dont want null values in any column. i want output as above. How to achieve this. If anybody knows please reply me. Thanks in advance.
This has nothing to do with .NET, so it should be posted in the Database forum. Oh, wait. You already posted it there[^]. And received an answer.
http://www.codeproject.com/Messages/3122367/How-to-get-an-answer-to-your-question.aspx[^]
9. Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer