例如:
select a.name, b.sex,b.image
from user a,pic b
where a.id=b.id
pic表的image字段是blob类型,连接查询就导致了获取不到结果,该怎么办呢?单表能查,2表连接就不行了?
select a.name, b.sex,b.image
from user a,pic b
where a.id=b.id
pic表的image字段是blob类型,连接查询就导致了获取不到结果,该怎么办呢?单表能查,2表连接就不行了?
调试欢乐多
select a.mail as Mail,
a.pass, -- 加了就查不出,,,万分奇怪
a.contactsection as contactsection,
a.contactfamilyname as contactfamilyname,
a.contactgivenname as contactgivenname,
a.contacttel as contacttel,
a.contactfax as contactfax,
a.contactmail as contactmail,
b.companyname as companyname,
b.companypostcode as companypostcode,
b.companyaddress as companyaddress,
b.companytel as companytel,
b.companyFax as companyFax,
b.companyestablisheddate as companyestablisheddate,
b.companyemployeenumber as companyemployeenumber,
b.companyURL as companyURL,
b.companyMemo as companyMemo,
b.companyevidence
from
m_user a,m_company b
where
a.companyid=b.companyid;
CREATE TABLE `cloudentrysystem`.`m_user` (
`Seqno` int(11) NOT NULL AUTO_INCREMENT,
`UserID` varchar(8) NOT NULL DEFAULT '',
`Pass` varchar(8) DEFAULT NULL,
`Mail` varchar(100) DEFAULT NULL,
`UserLevel` tinyint(4) NOT NULL DEFAULT '4',
`Valid` tinyint(4) DEFAULT '1',
`CompanyID` int(11) DEFAULT NULL,
`ContactSection` varchar(30) DEFAULT NULL,
`ContactFamilyName` varchar(20) DEFAULT NULL,
`ContactGivenName` varchar(20) DEFAULT NULL,
`ContactTel` varchar(11) DEFAULT NULL,
`ContactFax` varchar(10) DEFAULT NULL,
`ContactMail` varchar(100) DEFAULT NULL,
`RegistDate` datetime DEFAULT NULL,
`DeleteDate` datetime DEFAULT NULL,
PRIMARY KEY (`Seqno`,`UserID`),
KEY `CompanyID` (`CompanyID`),
CONSTRAINT `m_user_ibfk_1` FOREIGN KEY (`CompanyID`) REFERENCES `m_company` (`CompanyID`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;DROP TABLE IF EXISTS `cloudentrysystem`.`m_company`;
CREATE TABLE `cloudentrysystem`.`m_company` (
`CompanyID` int(10) NOT NULL AUTO_INCREMENT,
`CompanyName` varchar(100) DEFAULT NULL,
`CompanyPostCode` varchar(15) DEFAULT NULL,
`CompanyAddress` varchar(200) DEFAULT NULL,
`CompanyTel` varchar(11) DEFAULT NULL,
`CompanyFax` varchar(10) DEFAULT NULL,
`CompanyEstablishedDate` year(4) DEFAULT NULL,
`CompanyEmployeeNumber` int(10) unsigned DEFAULT NULL,
`CompanyURL` varchar(200) DEFAULT NULL,
`CompanyMemo` varchar(200) DEFAULT NULL,
`CompanyEvidence` blob,
PRIMARY KEY (`CompanyID`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
1. 你的 create table xxx .. 语句
2. 你的 insert into xxx ... 语句 4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。