We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,220 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Baffled with SELECT LIKE / IN

Good Morning,

Hopefully someone can help me with a quick answer.

I have a transaction table with a 'description' column that contains a combination of the members name and some static information i.e. "'username' PURCHASE" or "'username' PAYMENT"

and a 'type' column that contains various types of transactions i.e. 'FEE' or 'EARN'

I have a list of usernames, and I need to get the transaction number from each of these records where the 'description' contains a username from the list and the 'type' ='FEE'.

I don't know how to use the LIKE with the % wildcard along with the IN (using a list)

Any help would be greatly appreciated.

Douglas

3
Contributors
3
Replies
3 Days
Discussion Span
4 Months Ago
Last Updated
4
Views
Question
Answered
showman13
Posting Whiz
307 posts since Feb 2010
Reputation Points: 27
Solved Threads: 3
Skill Endorsements: 0

not 100% on what you're looking at (seeing the table structure would help) .. explain TABLENAME or show create table TABLEANME.

but here goes...

SELECT [COLUMNS_NAMES] FROM [TABLENAME] WHERE DESCRIPTION LIKE "%searchterm%" AND type  IN ('FEE', 'EARN')

hope this helps. cheers.

Also, Mysql has a great refernece on their website ..
http://dev.mysql.com/doc/refman/5.0/en//string-comparison-functions.html#operator_like

loud_noises
Newbie Poster
1 post since Jan 2013
Reputation Points: 0
Solved Threads: 1
Skill Endorsements: 0

select * from table
where DESCRIPTION LIKE "%searchterm1%" or
DESCRIPTION LIKE "%searchterm2%" or
DESCRIPTION LIKE "%searchterm3%" or
DESCRIPTION LIKE "%searchterm4%"

urtrivedi
Posting Virtuoso
1,714 posts since Dec 2008
Reputation Points: 299
Solved Threads: 362
Skill Endorsements: 24

Thank you both for your responses...

Sorry for the long delay, but I got sidetracked again and emursed in another project.

On this question, I concluded it wasn't worth the time or struggle to find a cure for it, because it would be a one time use and the total number of records effected was under 100, so I just went through them one by one manually and made the necessary adjustments.

Thanks again for the responses, but I'm going to mark this as solved .

showman13
Posting Whiz
307 posts since Feb 2010
Reputation Points: 27
Solved Threads: 3
Skill Endorsements: 0
Question Answered as of 4 Months Ago by urtrivedi and loud_noises

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.2954 seconds using 2.68MB