Solved

How to Formulate SQL Query from List in Excel?

Posted on 2014-01-31
2
218 Views
Last Modified: 2014-02-20
I've got a list of 100 email addresses.

Need to query against the User table in MySQL, and return their records.

For single query, it's simple.

SELECT *
FROM `users`
WHERE `mail` LIKE 'a.d.vent.kx.mm@gmail.com'
LIMIT 0 , 30

Then I'm printing to PDF for reporting.

How can I expedite this with a hundred emails, than just kick out a single PDF with all hundred records?

My list is in a single column in an Excel file.
0
Comment
Question by:sandshakimi
2 Comments
 
LVL 15

Expert Comment

by:JimFive
ID: 39824184
Bring the list into a temporary table in mySQL and then query:
SELECT *
FROM Users
INNER JOIN tmpList
ON Users.Mail = tmpList.Mail

Open in new window

0
 
LVL 11

Accepted Solution

by:
John_Vidmar earned 500 total points
ID: 39829399
Use an in-clause:
SELECT	* 
FROM	users
WHERE	mail IN
	(	'email001@whatever.blah'
	,	'email002@whatever.blah'
	...	...
	,	'email100@whatever.blah'
	)

Open in new window

0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now