Forums
This topic is locked
SQL not performing multiple LIKE/OR statements
19 Feb 2003 17:17:16 Erik Mr. posted:
I have generated a SQL string like below:
SELECT * FROM opportunity, codes WHERE opportunity.TypeCode = codes.TypeCode AND opportunity.TypeCode LIKE 'I-A%' OR opportunity.TypeCode LIKE ' II-A %'
Can anyone see why the SQL is only returning the values associated with the first LIKE statement and not the second as well?
thanks,
Erik
Replies
Replied 19 Feb 2003 18:02:30
19 Feb 2003 18:02:30 Brent Colflesh replied:
Dear Erik,
SELECT * FROM opportunity, codes WHERE opportunity.TypeCode = codes.TypeCode AND (opportunity.TypeCode LIKE 'I-A%' OR opportunity.TypeCode LIKE ' II-A %')
Regards,
Brent
SELECT * FROM opportunity, codes WHERE opportunity.TypeCode = codes.TypeCode AND (opportunity.TypeCode LIKE 'I-A%' OR opportunity.TypeCode LIKE ' II-A %')
Regards,
Brent
Replied 19 Feb 2003 18:27:40
19 Feb 2003 18:27:40 Erik Mr. replied:
Hi Brent:
I add the ( )'s
(opportunity.TypeCode LIKE 'I-A%' OR opportunity.TypeCode LIKE ' II-A %')
But results still only come back for the first LIKE statement. have any ideas?
[
quote]
Dear Erik,
SELECT * FROM opportunity, codes WHERE opportunity.TypeCode = codes.TypeCode AND (opportunity.TypeCode LIKE 'I-A%' OR opportunity.TypeCode LIKE ' II-A %')
Regards,
Brent
I add the ( )'s
(opportunity.TypeCode LIKE 'I-A%' OR opportunity.TypeCode LIKE ' II-A %')
But results still only come back for the first LIKE statement. have any ideas?
[
quote]
Dear Erik,
SELECT * FROM opportunity, codes WHERE opportunity.TypeCode = codes.TypeCode AND (opportunity.TypeCode LIKE 'I-A%' OR opportunity.TypeCode LIKE ' II-A %')
Regards,
Brent
Replied 19 Feb 2003 18:40:43
19 Feb 2003 18:40:43 Brent Colflesh replied:
Dear Erik,
Then your data does not match the query - also, you don't have spaces in this:
' II-A %'
like you do in your post?
Regards,
Brent
Then your data does not match the query - also, you don't have spaces in this:
' II-A %'
like you do in your post?
Regards,
Brent
Replied 19 Feb 2003 19:09:02
19 Feb 2003 19:09:02 Erik Mr. replied:
Thanks Brent:
It was the space. Good eyes!
It was the space. Good eyes!