0

what is the syntax of sql query has intersection between 2 "where Like" condition

string command_get_pay = "select Credit 
                            from Update_Company_Credit 
                           where ( Update_Date LIKE '%" + 8 + "%'& Update_Date LIKE 18'%" + 8 + "%')";`

is this true I try it but I got exception in syntax

4
  • Why did you mark the previous question as answered: stackoverflow.com/questions/3508024/sql-like-query-syntax Commented Aug 18, 2010 at 2:18
  • because after I read it is answer I know that you can't search for string in Datetime and I try to search in integer or datetime and it worked Commented Aug 18, 2010 at 2:25
  • @OMG Ponies: Why the backtick? Commented Aug 18, 2010 at 2:25
  • @OMG Ponies: There is a backtick at the end of the last line -- revision history seems to think you added it. Typo? Commented Aug 19, 2010 at 0:57

2 Answers 2

2

Do you mean:

SELECT
    Credit
FROM
    Update_Company_Credit
WHERE
    Update_Date LIKE '%" + 8 + "%'
    AND Update_Date LIKE 18'%" + 8 + "%'
;

Also, LIKE takes a string to use for search, but your second LIKE appears to be invalid... what is 18'%" + 8 + "%')"?

Edit: Oh, this is C#. Still makes no sense: how are you adding a string and an integer?

Sign up to request clarification or add additional context in comments.

7 Comments

I think he wants probably OR, because a column can't be 2 values at the same time
sorry 18'%" + 8 + "%')" is wrong it is only LIKE '%" + 8 + "%')"
Well, he says "intersection", which is an AND kind of operation. A LIKE '%blue%' AND LIKE '%green%' can match rows, and is different from the same statement with OR. His statements seem to follow this pattern, so, ideally, he should clarify which is intended...
@salamonti: That's a little clearer, but if this is C#, how are you adding a string and an integer?
normal I tried 1 'Like' condition with integer and I didn't got exception and it worked because I search in datetime type
|
0

the & should be probably OR?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.