sql中的join
string sql= "select orderdetail.*, order.postdate,member.UserName from orderdetail inner join member on order.id= member.id inner join order on order.id=orderdetail.id ";
这条语句错在什么地呢....大家大哥大姐们,帮帮忙.
[解决办法]
报什么错??
[解决办法]
你是用在ACCESS中吧。
try
select orderdetail.*, order.postdate,member.UserName from (orderdetail inner join member on order.id= member.id) inner join order on order.id=orderdetail.id
[解决办法]
string sql= "select orderdetail.*, order.postdate,member.UserName from orderdetail inner join order on order.id=orderdetail.id inner join member on order.id= member.id ";
[解决办法]
我上面不是寫了方法嗎?
ACCESS中多表關聯的寫法和在MS SQL中的寫法有區別的。
select orderdetail.*, order.postdate,member.UserName from (orderdetail inner join member on order.id= member.id) inner join order on order.id=orderdetail.id
[解决办法]
string sql= "select orderdetail.*, order.postdate,member.UserName from orderdetail inner join order on order.id= member.id inner join order on member.id=orderdetail.id where id= "+ Request.QueryString[ "ID "]+ " "
-----------
你這寫的什麼語句?
關聯了order兩次,卻沒有關聯member表。
try
string sql= "select orderdetail.*, order.postdate,member.UserName from (orderdetail inner join order on order.id= orderdetail.id) inner join member on member.id=orderdetail.id where orderdetail.id= "+ Request.QueryString[ "ID "]+ " ";............
[解决办法]
paoluo(一天到晚游泳的鱼) 的意见不知道对不,try
where id= "+ Request.QueryString[ "ID "]+ " ";............
感觉没有写清楚是哪个表的id
[解决办法]
nyzfl(小丫头是我心爱的女人 My-Blog地址:http://blog.csdn.) ( ) 信誉:96 Blog 加为好友 2007-06-25 11:12:22 得分: 0
paoluo(一天到晚游泳的鱼) 的意见不知道对不,try
where id= "+ Request.QueryString[ "ID "]+ " ";............
感觉没有写清楚是哪个表的id
---------
這裡的確有問題,所以我加上了“orderdetail.”。
[解决办法]
在每个表,每个字段名上加上 "[] ",如
select [orderdetail].*, [order].[postdate],[member] ....
order是关键字,在ACCESS中无法区别,就报错了
在SQLSERVER中是可以识别的
[解决办法]
的確是這個問題,不過這麼修改一下即可.
string sql= "select orderdetail.*, order.postdate,member.UserName from (orderdetail inner join [order] on order.id= orderdetail.id) inner join member on member.id=orderdetail.id where orderdetail.id= "+ Request.QueryString[ "ID "]+ " ";