select did,count,
( select title from wds_dishes where did=did limit 1 ) 
as title from wds_shopping_cart inner join wds_dishes 
on did=did where uid=1

现有两张表:
购物车表wds_shopping_cart
菜品信息表wds_dishes

现想通过购物车表中获取的菜品id,到菜品信息表中查出对应的标题和价格,连接在查询结果之后。但是当两表的菜品id都叫做did时,SQL语句报错如下:

SQL多表查询出错(Column 'did' in field list is ambiguous)
由于两表中did名称相同,所以在查询时产生模棱两可的情况,所以在建表时要注意相互嵌套的id不要重名。

相关文章:

  • 2022-01-08
  • 2021-08-18
  • 2022-01-04
  • 2021-09-22
  • 2021-11-29
  • 2022-12-23
  • 2021-11-26
猜你喜欢
  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案