mysql4.1以下版本不支持子查询,建议升级。SELECT * FROM cx_msg WHERE id IN (SELECT id FROM jb_msg);
可以用左连接改写:
SELECT cx_msg.* FROM cx_msg,jb_msg where cx_msg.id=jb_msg.id;

解决方案 »

  1.   

    CREATE TABLE `stocktype` (
      `id` int(6) NOT NULL auto_increment,
      `TypeName` varchar(50) default NULL,
      `parentId` tinyint(4) NOT NULL default '0',
      `depth` tinyint(4) NOT NULL default '0',
      PRIMARY KEY  (`id`)
    ) TYPE=InnoDB如果我想查询表中parentId 没有对应的id的记录应该怎么写?
    例如:
    id    typename     parentId   depth
    1     aaaaa         0          0
    2     bbbbb         1          1
    3     ccccc         5          1
    上表中记录3的parentid是5,id中没有一个5的记录和他对应。请问我应该怎么写查询语句啊?
      

  2.   

    select id,typename,parentId,depth from stocktype left join 表 on stocktype.parentId=表.parentId where 表.parentId is null
      

  3.   

    to XqYuan() 
    问题是我都操作都是stocktype表,按你的意思就是
    select id,typename,parentId,depth from stocktype left join stocktype on stocktype.parentId=stocktype.parentId where stocktype.parentId is null
    不行啊!可以有解决办法吗?
      

  4.   

    select id,typename,parentId,depth from stocktype left join stocktype as a on stocktype.parentId=a.parentId where a.parentId is null