易截截图软件、单文件、免安装、纯绿色、仅160KB

mysql子查询 - 其他数据库开发 / MySQL/Postgresql

表A:
ID,Name
表B:
ID,Name
现查询表A,想知道表B中有无ID相同的记录,如有则显示有几条,下面语句在mysql中无法执行
select 
ID,
Name,
(select cont(*) from 表B where ID=表A.ID)表B_ID

from 表A
mysql版本,提示什么

错误代码1064-you have an eror in your SQL syntax.Check the manual that corresponds to your MySQL server version for the right syntax to use near'(select count(*) from 表B where ID=表A.ID)'

select `ID`,`Name`,
(select count(*) from 表B where `ID`=表A.`ID`) as `表B_ID` from 表A

你的mysql 版本是什么?

另外你贴出的语句和报错的信息并不一致!

(select cont(*) from 表B where ID=表A.ID)表B_ID
syntax to use near'(select count(*) from 表B where ID=表A.ID)'

建议准确贴出你的语句,这样减少误导。

mysql版本是4.0.27-log;
(select cont(*) from 表B where ID=表A.ID)表B_ID
syntax to use near'(select count(*) from 表B where ID=表A.ID)'
上面一句cont(*)写错了,应该是count(*)。
谢谢!
就是想实现查询表A时看表B中有无ID相同的纪录。


表A中还有字段EmployeeID
表A:
ID,Name,EmployeeID
表C:
EmployeeID,EmployeeName
现在想同时列出EmployeeName,达到如下效果:
ID,Name,count,EmployeeID,EmployeeName

你自己加一下不就行了吗?

SQL code:
select 表A.ID,表A.Name,count(表B.ID)


相关问答:

mysql连接tomcat - Java / Web 开发

我已经按照教程上配置tomcat的server.xml
<Context path = "/POS" docBase = "POS" debug = "5" reloadable = "true" crossContext = "true" workDir = &quo ......

myeclipse+mysql的配置问题 - Java / Eclipse

我是个新手,望高手解答
我现在已经安装了mysql,也有mysql的jdbc。但我怎么配置后,才能在MyEclipse里操作mysql呢?请高手说详细点
打开Myeclipse----window---open perspective---MyEclipse database explorer-- ......

mysql预处理 - 其他数据库开发 / MySQL/Postgresql

SQL code:

create procedure proc_batchUpdate(in categoryId integer , in artIds varchar(50))
begin
set @dsql = count('update article set type=' , categoryId , ' where id in (' , artIds , ' ......

mysql区没高手 - MS-SQL Server / 基础类

我觉得mysql和sqlserver有共同的地方:
有个问题是关于表的锁问题:
进程A 进程B
select * from user where id in lock share mode(共享锁)
&nb ......

MySQL数据库存放在哪啊? - MS-SQL Server / 基础类

怎么找到数据库的位置啊?请各位前辈指教一下?小的非常感谢!
先找到my.cnf文件,打开后看[data]下的datadir


2、进入mysql终端:
mysql>show variables like '%datadir%';

再不行全盘搜索: frm文件 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号