0

I have 2 tables "data" and "listings" that I'm doing a LEFT join on. Both tables have an ID column. The problem is, I can't figure out how to do AS with a join so I can later reference data.ID and listings.ID in my PHP script. Here's my current query, which results in 2 columns both labeled ID

`SELECT * FROM `listings` LEFT JOIN `data` ON ( `listings`.`REALTOR` = `data`.`ID` ) WHERE `listings`.`ACTIVE` = '1' AND `listings`.`MODIFIED` < NOW( ) - INTERVAL 90 DAY `

1 Answer 1

1
SELECT l.*, d.*,
       l.id as listing_id, 
       d.id as data_id
FROM listings l
LEFT JOIN data d ON l.REALTOR = d.ID
WHERE l.ACTIVE = '1' 
AND l.MODIFIED < NOW() - INTERVAL 90 DAY
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I was SO CLOSE ! One of my many attempts was id as l.listing_id UGH

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.