I use following to get data from two tables:
SELECT p.id, p.title, p.event_date, a.name, p.location_id FROM ixrsk_eb_events p INNER JOIN ixrsk_eb_locations a on p.location_id = a.id
This works fine.
Now in addition, I want to have column headings.
On top of the results: “ID” (col
p.id), “Title” (col
p.title), “Date” (col
p.event_date) and “Location” (col
p.location_id should not be displayed at all (no heading, no data).
How can I do this?
you can use aliases to change the names of the columns you show:
SELECT p.id AS ID, p.title AS Title, p.event_date AS Date, a.name AS Location FROM ixrsk_eb_events p INNER JOIN ixrsk_eb_locations a on p.location_id = a.id
and just leave out the columns you do not want to show up.