简体   繁体   中英

how to filter data with checkbox click?

i have filter from SQL and i use AND condition for that , i want to filter like if i check two check box then data comes combination of two ,if check three then data comes combination of three but in my case if i selected one check box then data comes as i like but if i select multiple then no record comes...how to get records:-

IF(@USER_TYPE_S !=0)    SELECT @SQL =   @SQL+' AND USER_ID=@XP_STUDENT'  
IF(@USER_TYPE_BUIL !=0) SELECT @SQL =   @SQL+' AND USER_ID=@XP_DEALER'
IF(@USER_TYPE_B !=0)    SELECT @SQL =   @SQL+' AND USER_ID=@XP_CUTOMER'
IF(@USER_TYPE_OWN !=0)  SELECT @SQL =   @SQL+' AND USER_ID=@XP_OWNER'

SELECT @PARAMETER_LIST='@XP_STUDENT INT,@XP_DEALER INT,@XP_CUTOMER INT,@XP_OWNER INT'
INSERT INTO #TEMP(PROJECT_ID)

EXEC SP_EXECUTESQL @SQL,@PARAMETER_LIST,@USER_TYPE_S,@USER_TYPE_BUIL,@USER_TYPE_B,@USER_TYPE_OWN

In your case the SQL Query before executed on the Server would be something like

Select * from table where USER_ID="Test1" AND USER_ID="Test2"...

So, are you sure there will be such records with USER_ID matching different filters. Perhaps you are required to use OR condition instead of AND condition

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM