March 12, 2012 at 11:40 am
I'm trying to formulate a query against two tables, but it isn't working correctly. Essentially what I need is this...
select * from table1 where somecolumn like '%somevalue%' and somevalue like '%something%' from table2
March 12, 2012 at 11:51 am
March 12, 2012 at 11:53 am
I want to combine the following statements into one, and join the results together.
select * from table1, table2 where table1.status like '%something%' and table2.function like '%somethingelse%'
Intended output should display column 1 with the status that I am filtering by with the like statement, and column 2 will further filter on this, if that makes sense. I'd rather not get too proprietary.
March 12, 2012 at 12:10 pm
Please see this link http://www.sqlservercentral.com/articles/Best+Practices/61537/
as far as the proprietary make up the data, make up the names. we dont need your production data but we do need something like this:
CREATE TABLE #Foo(
SomeINT INT,
Status VARCHAR(35)
)
CREATE TABLE #Bar(
SomeINT INT,
Function VARCHAR(64)
)
INSERT INTO #Foo
SELECT 1, 'Good' UNION ALL
SELECT 2, 'Bad'
INSERT INTO #Bar
SELECT 1, 'MakeBad' UNION ALL
SELECT 2, 'MakeGood'
then put how you want the data to look.
this way we have the structure we are going to be trying to help you with and what the outcome should be. Right now your asking "what kind of car should i get?" but failing to mention you are going to try driving in a NASCAR race. Details matter.
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]
March 12, 2012 at 12:13 pm
Not what was requested.
Please read the first article I reference in my signature block regarding asking for help. Follow the instructions in that article regarding what and how to post the information we need to help you. Be sure to post the expected results based on the sample data you provide for your tables.
March 12, 2012 at 1:33 pm
Read this one, I think this what you are looking for.
http://msdn.microsoft.com/en-us/library/ms180026.aspx
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply