I have 2 tables,
admin, pricing
I want to do a select that joins the two tables where pricing.relation = admin.id
How do I rename the value, id and date_created rows so they do not overwrite each other?
This is the kinda thing i'm trying:
$sub_types = $database->query('
SELECT
pricing.*,
admin.*
FROM
pricing,
admin
WHERE pricing.relation = admin.id
');
You can use aliases:
SELECT p.id as pid,
p.date_created as pricing_date,
p.type, p.value as pricing_value,
a.id as aid,
a.date_created as admin_date,
a.relation,
a.value as admin_value
FROM pricing p
inner join admin a on p.relation = a.id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With