MySQL Forums
Forum List  »  Newbie

Re: Operand should contain 1 column(s) - how to get extra info from subquery?
Posted by: Alan Densmore
Date: February 05, 2019 05:23PM

Peter thanks so much for the help -
I see how yours is simpler/cleaner, and I didn't know about ifnull() etc. - that seems like it could help, I tweaked it to what I needed to test:

-----------------
select

p.*,
ifnull(t.persontag_enddate,'Unknown') as 'expiry date',
date_format(t.persontag_enddate, '%M %e, %Y') as display_persontag_enddate

from
persons p
left join
persons_tags t using(person_id)

where

p.person_withdrawn != 1
and
(
t.persontag_startdate < now()-interval 3 year
and
t.tag_id = 170
)

order by person_last, person_first;
-----------------

The main thing I know that I need more than the above though, is to ALSO return persons that are *NOT IN* the join table (t) *AT ALL*, while still returning that display_persontag_enddate info for the people who *ARE* in it.

It's that combo I don't know how to achieve and still get the extra "display_persontag_enddate" info when it exists (when they ARE in the join table). Does that make sense?

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.