本文介绍了如何在SQL查询中传递多个城市id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我的sql查询如下



选择DISTINCT date_TripDate AS TripDate,traveltype.varchar_TravelTypeCode AS TripType,contactss.Value as Mobilenumber,来自[OneC_988]。[dbo] 。[988_Details_VehicleRequest]请求加入[OneC_988]。[dbo]。[988_Details_VehicleTrip] trip on request.int_VehicleRequestID = trip.int_VehicleRequestID

和int_CityID ='1'



当我运行上面的查询输出如下



Tripdate TripType Mobilenumber int_CityID



26th aug 16 IN 9878778878 1

26th aug 16 IN 9949949990 1

26th aug 16 IN 9878778878 1







i想要在上面的sql查询中传递INT_CityID 1和2以获得如下输出



Tripdate TripType Mobilenumber int_CityID



26th aug 16 IN 9878778878 1

26th aug 16 IN 9949949990 1

26th aug 16 IN 9878778878 1



28th aug 16 IN 9878778878 2

28th aug 16 IN 9949949990 2

28th aug 16 IN 9878778878 2



我尝试了什么:



如何在sql查询中传递多个城市id

解决方案

My sql query as follows

select DISTINCT date_TripDate AS TripDate,traveltype.varchar_TravelTypeCode AS TripType,contactss.Value as Mobilenumber,from [OneC_988].[dbo].[988_Details_VehicleRequest] request join [OneC_988].[dbo].[988_Details_VehicleTrip] trip on request.int_VehicleRequestID=trip.int_VehicleRequestID
and int_CityID ='1'

When i run the above query output as follows

Tripdate TripType Mobilenumber int_CityID

26th aug 16 IN 9878778878 1
26th aug 16 IN 9949949990 1
26th aug 16 IN 9878778878 1



i want to pass both INT_CityID 1 and 2 in the above sql query to get output as follows

Tripdate TripType Mobilenumber int_CityID

26th aug 16 IN 9878778878 1
26th aug 16 IN 9949949990 1
26th aug 16 IN 9878778878 1

28th aug 16 IN 9878778878 2
28th aug 16 IN 9949949990 2
28th aug 16 IN 9878778878 2

What I have tried:

how to pass mutiple city id in sql query

解决方案


这篇关于如何在SQL查询中传递多个城市id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 12:26