Thanks, that worked but the results are alternating instead of being combined into the same row. See below for simple example:
users DB columns:
uID | ufname
1 | John
2 | Mike
matchmaker DB columns:
mmparID | mmpreID
1 | 2
I want to show 'John' and 'Mike' in the same row in my...
Having a problem combining 2 JOINS. Both statements below work. I have also included the relevant fields in the 2 DBs. My question is:
1) How do I combine the 2 statements into 1 statement?
2) How do I reference the rows in my php to distinguish if the result was from the mmpreID JOIN or the...
The query (B) below is working, but in the first LEFT JOIN I'd like to pull the most recent result. So, I'd have to add something like the query (A) below in somehow.
A
SELECT poArID, poDatetime FROM posts ORDER BY poDatetime DESC
B
SELECT articles.arID, articles.arType, articles.arTitle...
Yes, that helps, thanks. Fortunately, pulling any of the purl values associated with that cID satisfies what I need to do. However, I will look at the aggregate function so I can make the query more accurate.
Again, thanks for your help.
This did it:
SELECT ppre.cID, ppre.yr, ppre.make, ppre.model, ppre.vin, ppre.display, TR.purl FROM ppre INNER JOIN ( SELECT DISTINCT pcID, purl FROM ppics ) AS TR ON TR.pcID = ppre.cID GROUP BY ppre.cID
Thank you
Right, an extra column.
However, the SQL you provided shows all the results (not right). My original statement showed just the distinct TR.pcID's (right), but I am just trying to pull in the associated value from the ppics.purl in the same row as the TR.pcID. Sorry if I am not being clear.
The following is working great, but I need to get one more row from the second table (ppics). However, when I try to add this in, my query stops working. Any help will be much appreciated.
SELECT ppre.cID, ppre.yr, ppre.make, ppre.model, ppre.vin, ppre.display FROM ppre
JOIN (SELECT DISTINCT...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.