易截截图软件、单文件、免安装、纯绿色、仅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预处理 - 其他数据库开发 / 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 / 基础类

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


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

再不行全盘搜索: frm文件 ......

mysql建表错误 - 其他数据库开发 / MySQL/Postgresql

用mysql建表时出现错误1067 :invalid default value for 'id'
id是int型的,为什么不能设置默认值。语句为id int(4)default '-1' null;出现错误。
贴出你的 create table 语句,及你的mysql 版本。

当您的问 ......

mssql函数翻译 - 其他数据库开发 / MySQL/Postgresql

跪求将以下函数翻译为 mysql 的语法
CREATE FUNCTION workdayadd( 
@date datetime, --基础日期 
@workday int --要增加的工作日数 
)RETURNS datetime 
AS 
BEGIN 
DEC ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号