Hello there I wonder if the following is possible (in MySQL): There is a simple query joining two tables:
SELECT * FROM `contact_attending_appointment` AS tcon,`contact` AS tget WHERE tcon.appointment_id = 2 AND tget.id = tcon.contact_id;
This query will return the values of both tables - tcon and tget - joined together. However, I want only to have the columns of ONE table.
Basically in SQL you achieve it like this:
SELECT col_1,col_2,...,col_n FROM ...
Or you get all the columns with
SELECT * FROM ...
However I would like to have something like (as I do not know the columns of tget by their names)
SELECT [* from tget] FROM ...
Is there a general solution for this or is this not possible?
SELECT tget.* FROM contact AS tget ...
The question has already been answered by Rafa. But you seem to be learning SQL. The following is a better way of writing your query:
SELECT c.*
FROM `contact_attending_appointment` caa INNER JOIN
`contact` c
ON c.id = caa.contact_id
WHERE caa.appointment_id = 2;
The important changes are:
on
clause rather than in the where
.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