Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

How to Formulate SQL Query from List in Excel?

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
sandshakimi
Asked:
sandshakimi
1 Solution
 
JimFiveCommented:
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
 
John_VidmarCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now