php - Returning data from multiple tables in one query even if secondary tables do not apply -


I have a problem getting data from three tables, which I want to use a query. I have done this before using some queries like this:

  $ query = mysql_query ("Choose manageable.Id ', Maintenance. Eomedata', maintable.asubtable1_id`, subtable1` `` `` `'' '' '' '' '' '' '' '' '' '' '' '' '` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `)` `` `` 2`` "or" die "(mysql_error ());  

The problem is that additional details may not actually be implemented.

I need some things that are able to maintain

  I `somedata` = 'some_search' and if maintenance is qualified,` `` ` `` `` `` `Until then can not be pressure. '' `` ============================================== ================================================== ===================> 

As you might guess, I'm not an advanced mysql user! As much as possible, I can not get the syntax correct, and I have no luck finding the solution on the web.

Any help much appreciated!

If you have received this right, you should use MySQL LEFT Have to do. Try it: Select

  from m.id, m.somedata, m.subtable1_id, s1.somedata, s1.subtable2_id, s2.somedata to exclude maintenance m subtable1 s1 m.subtable1_id = S1 .id LEFT JOIN subtable2 s2 ON s1.subtable2_id = s2.id WHERE m.somedata = 'Some Search'  


Keeping this compatible will return the data, even if There is no equivalent in data or maintenance in subtitles 1 or 2 and data of sub-table 1 if sub-bag 2 does not have equivalent data.


Comments