Mysql - make query returns empty string value instead of empty result set for nested query?

Did you try something like this: SELECT `table_b`. * FROM `table_b` LEFT JOIN `table_a` ON (`table_b`. `id`=`table_a`.

`link_id`) WHERE `table_a`. `link_id` IN (1,2,3); With LEFT JOIN table_b would return fields with null values.

Ok I saw your comment to your question a little too late. Did you try to use "mysql stored procedures"? – FlyBy Jul 28 at 10:17 thanks for the answer but the query I have is a little more complicated than the one I put in the example (my fault).

I was trying to simplify it but by doing so removed another problem which is that table_b is not just one table but a number of differnet tables so can't just do a join like you suggest. See my comment above. Thanks for the help and if you have any other suggestions I'd be happy to see them – John Jul 28 at 10:20 1 I go the feeling you have to rethink your problem a little bit and use stored procedures or just explain your problem a better way!

:D – FlyBy Jul 28 at 10:22.

Well, you are not helping us help you by providing a detailed query, however based on your code, this is what I could come up with: SELECT DISTINCT ta1. ColName item1, ta2. ColName item2, ta3.

ColName item3 FROM table_a ta1 LEFT JOIN table_a ta2 ON ta2. Link_id = ( SELECT id FROM table_c WHERE col_id = 7 AND somefield = 'some_other_text' ) LEFT JOIN table_a ta3 ON ta3. Link_id = ( SELECT id FROM table_m WHERE col_id = 121 AND somefield = 'more_text' ) WHERE ta1.

Link_id = ( SELECT id FROM table_b WHERE col_id = 1 AND somefield = 'some_text' ) You can do this with LEFT JOINs only, if you would like to, but I added in the WHERE clause not to waste a table lookup. Ask me about anything that you don't understand.

Well, maybe it's not the most elegant solution, but it should do the job: SELECT item1. Value, item2. Value, item3.

Value FROM ( (SELECT value FROM table_a WHERE link_id = (SELECT id FROM table_b WHERE col_id=1 and somefield='some_text')) as item1 RIGHT JOIN (SELECT NULL) t1 ON TRUE ), ( (SELECT value FROM table_a WHERE link_id = (SELECT id FROM table_c WHERE col_id=7 and somefield='some_other_text')) as item2 RIGHT JOIN (SELECT NULL) t2 ON TRUE ), ( (SELECT id FROM table_m WHERE col_id=121 and somefield='more_text')) as item3 RIGHT JOIN (SELECT NULL) t3 ON TRUE ).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions