I have a challenge trying to merge output using PHP from two TABLES in a MySQL database. I am not sure how to put the SELECT string to get certain columns from both of the TABLES I want to pull data from.
In one TABLE I have a unique identifier (bid) and this identifier is also present in the second TABLE.
The first TABLE represents a ticket buyer (table name = eventoslotickerbuyer). And the second TABLE represents guests (table name = eventosloguests). The structure of the eventosloticketbuyer TABLE looks like this:
bid
firstname
lastname
email
cellphone
privatekey
eventid
orderdatetime
confirmeddatetime
The eventosloguests TABLE has the following structure:
gid
gfirstname
glastname
gemail
bid
eventid
registered
confirmed
confcode
What I want to accomplish, is to pull firstname and lastname from the "first" table, then pull gfirstname and glastname from the "second" table. The column that exists in both tables are the bid.
I can't figure out how the query should look like, so would appreciate some help.
Sincerely, Andreas
UPDATE:
I got it to work buy writing the query like this:
SELECT a.firstname, a.lastname, b.gfirstname, b.glastname
FROM eventosloticketbuyer a
INNER JOIN eventosloguests b ON a.bid = b.bid
What I still do not know is, if there is no GUEST connected to a BUYER, would this end up in blanks or should I switch it in some way to secure that I fetch the BUYER by using the GUEST as source?