Solved

How to Formulate SQL Query from List in Excel?

Posted on 2014-01-31
2
222 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword This article was written many years ago, in the days when PHP supported the MySQL extension (http://php.net/manual/en/function.mysql-connect.php).  Today (http://php.net/manual/en/migration70.removed-exts-sapis.php) you would not use MySQL…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 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