简体   繁体   中英

SQL add tablename as field

I have seen this done before but I can't remember where I saw it.

What I need to do is have the table name as a field in a query.

Say I have a table called users, how would I add the table name 'users' as a column.

Like:

 SELECT username, password, **table** as mytable FROM users

看起来很明显,但是您是否考虑了以下问题?

SELECT username, password, 'users' as mytable FROM users

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM