kmakan
kmakan

Reputation: 11

Selecting the current table in MySQL select query

I'd like to know if there was a simple function that determines the table(s) involved in a select query. Basically the tabular equivalent to CURDATABASE() ?

For instance:

Select * colname,colname,...,
from (sometablename)
where something = val union select from CURTABLE() ...;

Upvotes: 1

Views: 2858

Answers (1)

yati sagade
yati sagade

Reputation: 1375

The point is, single SELECT...FROM can have multiple tables:

SELECT * FROM T1, T2 WHERE T1.id = T2.id

etc. So having a single CURTABLE() doesn't make sense. But, you can use aliases to shorten and sometimes clarify your queries:

SELECT * FROM USERS U1, USERS U2 WHERE U1.FATHER_ID = U2.ID

etc. (That example is very contrived, but the point is aliases). Read up on the docs of your SQL engine to know further. If this was not what you intended to know, let us know, and someone might be able to help you.

Upvotes: 1

Related Questions