在哪里使用sqlserver [英] where in and like using sqlserver
本文介绍了在哪里使用sqlserver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的查询有问题。
例如
声明@skill varchar(100);
set @skill ='。net,java,php';
my查询是这样的
选择*来自作业,其中标题如'%'+ @ skill +'%';
但我想得到记录标题栏分别包含.net,java和php
我的意思是
Hi,
I have a problem in query.
for example
declare @skill varchar(100);
set @skill='.net,java,php';
my query is like this
select * from job where title like '%'+@skill+'%';
but I want to get records title column contains .net , java and php individually
I mean
select * from job where title like '%java%'
select * from job where title like '%.net%'
select * from job where title like '%php%'
我想在一个查询中获得这样的记录
技能动态变化。
请帮帮我。
谢谢。
I want get the records like this in a single query
skills are dynamically changed.
please help me.
Thank you.
推荐答案
使用分裂函数从字符串中提取单个技能:
T-SQL:最实用的分割功能 [ ^ ]
要返回符合任何技能的记录,请尝试以下方法: br />
Use a split function to extract the individual skills from the string:
T-SQL: Most Practical Split Function[^]
To return records which match any of the skills, try something like:
SELECT
*
FROM
jobs
WHERE
Exists
(
SELECT 1
FROM dbo.fn_split(@skill, ',') As S
WHERE job.title LIKE '%' + S.item + '%'
)
select job from job where jobskill IN('。net','java','php')
select * from job where jobskill IN('.net','java','php')
你听说过AND吗?运营商?我认为这很明显。
Have you ever heard of the AND operator? I thought this would have been obvious.
SELECT fieldList FROM job
WHERE jobskill LIKE '%java%'
AND jobskill LIKE '%.net'
AND jobskill LIKE '%php%'
也许您需要在自己的搜索中包含'%SQL%'?
Perhaps you need to include '%SQL%' in your own search?
这篇关于在哪里使用sqlserver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文