简体   繁体   中英

SQL subquery error not working

My SQL query is giving error while trying to execute query:

Error: Query input must contain at least one table or query

INSERT into Posts (PostText,TimePosted, TID) 
       VALUES ('My Post','2013-04-11 13:50:18',
             (SELECT MAX(TID) FROM Threads AS TID))

Combine the literal fields with the select & move the alias;

INSERT into Posts (PostText,TimePosted, TID) 
   SELECT 'My Post','2013-04-11 13:50:18', MAX(TID) AS TID FROM Threads

You have not specified table name in your query.

There are 3 fields in your table and you are sending 3 values (Last value by select query).

But you have not written table name for main query in which data to insert.

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