Answer the question
In order to leave comments, you need to log in
How to properly pull from two mysql tables?
users
table guests table
How to form a query to get a result like this:
fio
Ivanov ( last_name from the users table)
Petrov (last_name from the users table)
.... etc. (from the last_name users table)
Vasya Pupkin (guestname from the guests table)
... etc. (guestname from guests table)
Answer the question
In order to leave comments, you need to log in
SELECT DISTINCT last_name FROM users
UNION ALL
SELECT DISTINCT guestname FROM guests
table guests - whoinvited should store the id of the inviter, then you can join these tables by id and huinvited, but in any case - in one line you will not get ALL invitees in separate fields, or these will be lines duplicated in the user table and differing only in invited , or you can make a group buy huinvited and concat on the guestname, and there will be 1 field with a string value of all names.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question