Correct this sql
-
How to form this logic in a true sql? Select * from AdCampaign where category and language and keyword in (select sitecategory, language, keyword from Adzone)
-
How to form this logic in a true sql? Select * from AdCampaign where category and language and keyword in (select sitecategory, language, keyword from Adzone)
You can use a join. Use something like this:
select a.* from AdCampaign a inner join Adzone b
on a.category=b.sitecategory and a.language=b.language and a.keyword=b.keyword; -
You can use a join. Use something like this:
select a.* from AdCampaign a inner join Adzone b
on a.category=b.sitecategory and a.language=b.language and a.keyword=b.keyword;Could I replaceany of the dqual "=" into "like"?
-
Could I replaceany of the dqual "=" into "like"?
You will need to give further details about your requirement. What do you want to achieve with "like"? In SQL "like" matches a pattern, similar to using wild cards. In your case, you seem to mean something else. I may not be able to answer your question, but if you offer more details, somebody else may have an answer.
-
You will need to give further details about your requirement. What do you want to achieve with "like"? In SQL "like" matches a pattern, similar to using wild cards. In your case, you seem to mean something else. I may not be able to answer your question, but if you offer more details, somebody else may have an answer.
I had an error with % at end of query <pre>select a.AdHeadline,a.AdText,a.DisplayUrl, a.TargetUrl from AdCampaign a inner join Adzone b on a.sitecategory=b.category and a.language=b.language and a.keyword like %b.keyword%;</pre> Error: Msg 102, Level 15, State 1, Line 2 Incorrect syntax near 'b'.
-
I had an error with % at end of query <pre>select a.AdHeadline,a.AdText,a.DisplayUrl, a.TargetUrl from AdCampaign a inner join Adzone b on a.sitecategory=b.category and a.language=b.language and a.keyword like %b.keyword%;</pre> Error: Msg 102, Level 15, State 1, Line 2 Incorrect syntax near 'b'.
make it as
'%'+b.keyword+'%'
-
I had an error with % at end of query <pre>select a.AdHeadline,a.AdText,a.DisplayUrl, a.TargetUrl from AdCampaign a inner join Adzone b on a.sitecategory=b.category and a.language=b.language and a.keyword like %b.keyword%;</pre> Error: Msg 102, Level 15, State 1, Line 2 Incorrect syntax near 'b'.
USE pubs IF EXISTS (SELECT name FROM sysobjects WHERE name = 'au_info2' AND type = 'P') DROP PROCEDURE au_info2 GO USE pubs GO CREATE PROCEDURE au_info2 @lastname varchar(30) = 'D%', @firstname varchar(18) = '%' AS SELECT au_lname, au_fname, title, pub_name FROM authors a INNER JOIN titleauthor ta ON a.au_id = ta.au_id INNER JOIN titles t ON t.title_id = ta.title_id INNER JOIN publishers p ON t.pub_id = p.pub_id WHERE au_fname LIKE @firstname AND au_lname LIKE @lastname
this example was taken from msdn like examplesMarc Clifton wrote:
That has nothing to do with VB. - Oh crap. I just defended VB!