eddiejoeP
eddiejoeP

Reputation: 3

MYSQL Simple Query - Need Union Alternative

I have a MYSQL table called "registrations"

id    license           price     attachment_id (maps back to the same table)
33    Description A      10            35
34    Description B      15            0
35    Description C      18            0
36    Description D      5             37
37    Description E      10            0

I need to get the row where id = 33 and output ANOTHER ROW where the attachment_id column matches the "id" column in the same table.

So, the output should be:

id    license           price     attachment_id (maps back to the same table)
33    Description A      10            35
35    Description C      18            0

How can I do this without a UNION?

Upvotes: 0

Views: 56

Answers (1)

overflowed
overflowed

Reputation: 1838

Possible:

select * from registrations where
id = 33 or id = (select attachment_id from resgistrations where id = 33)

Upvotes: 1

Related Questions