Reputation: 87
I have the following select statement:
SELECT
*
FROM
jobs
LEFT JOIN bids
ON jobs.userID = bids.jobID
WHERE
bids.bidder = '$userName'
But this statement does only show the results from the "jobs" table. I also want to show results from the "bids" table, for example the column "bids" from the table bids.
How do I combine that in the above select statement?
Upvotes: 2
Views: 58
Reputation: 2420
The *
in Select * From... shows only the columns from your From-line. If you wanna Columns from your join-table, you have to add the column like this: bids.. if you use a alias (b and j in my example) it is easier to reading the statement... you also can use a "wildcard" in your select statement for your jointables.. like this bids.* (b.*)
in your case you need this:
SELECT j.*, b.*
FROM jobs j
LEFT JOIN bids b
ON j.userID=b.jobID
WHERE b.bidder = '$userName'
Upvotes: 1