SQL语言查询表中固定的字段

来源:百度知道 编辑:UC知道 时间:2024/05/31 20:46:06
如图所示~我想查询所有经过"友谊路"到“哈一百”的车辆~SQL语句该怎么写?急急急~~~~~
非常感谢楼下几位的回答~图中的表只是我的一个部分,我一共有45个车站~我该怎么用循环查询啊?

貌似简单,那就简单些搞:

select * from tb where charindex('友谊路',车站1+车站2+车站3+车站4+车站5)>0 and charindex('哈一百',车站1+车站2+车站3+车站4+车站5)>0

或者用下面的语句也可以的啦

select * from tb where 车站1+车站2+车站3+车站4+车站5 like '%哈一百%'
and 车站1+车站2+车站3+车站4+车站5 like '%友谊路%'

select * from 表 where (车站1 = '友谊路' or 车站2 = '友谊路' or 车站3 = '友谊路' or 车站4 = '友谊路' or 车站5 = '友谊路' )and( 车站1 = '哈一百' or 车站2 = '哈一百' or 车站3 = '哈一百' or 车站4 = '哈一百' or 车站5 = '哈一百' )

select *from 表 where 车站 like '%友谊路%' and 车站 like '%哈一百%'
这样好像也可以

你说要找车辆,那只有一个表吗?
这个应该是连接查询的啊