繁体   English   中英

在MySQL查询中添加“计数”,并在“ from”子句中添加多个表

[英]Adding 'count' in MySQL query with multiple tables in 'from' clause

我有以下MySQL查询:

select * from u, s, c, ut, m 

可以正常工作,显示所有表的所有列。 我只想将记录计数添加到u表中。

我尝试了这个:

select (select count(*) as totalcount from u), * from u, s, c, ut, m 

但它抛出一个错误。

这个查询对我有用:

select * , (select count(*) from u) as totalcount from u , s , c , ut , m ;  

SELECT t1.*, (SELECT COUNT(*) FROM table t3) AS TotalCount FROM table_Name1 t1, tableName t ;

这可能对您有帮助。 指定要从中检索表的列。 如果您希望所有列都更好,则最好的方法是join表。

select (select count(*) as totalcount from u), * from u, s, c, ut, m 

我尝试您的查询,它工作正常。 尝试一下。 我希望它能起作用。

select (select count(*) from u) as totalcount, * from u, s, c, ut, m 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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