Urgent SQL Query Help needed

Without PhpMyAdmin, I’m struggling with Queries. We had a provider give notice and we need to send letters to all their patients as soon as possible but the Batch com page doesn’t have an option in the dropdown to sort and generate a .csv file by provider, what would I need to do to add it? or would anyone be willing to write a query that produces a zip code sorted file we would need for a mail merge?

Why not just install it outside EMR?

1 Like

Without details on your working environment, I’d start with something like this;

SELECT fname,lname,street,city,state,postal_code from patient_data WHERE providerID = ‘#’ ORDER BY postal_code INTO OUTFILE ‘/var/lib/mysql-files/pat_list_1.csv’ FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘"’ LINES TERMINATED BY ‘\n’;`

Input the providerID in question to replace the # , and you might need to adjust the file output path.
Beware that if your SQL user does not have the FILE privilege, and your MySQL/MariaDB daemon is not configured to allow direct outfile writing to disk, then you’ll need to make adjustments before it will work. But, that will give you a list for the provider sorted by ZIP code, and you can import the CSV file into Calc or Excel and make further edits as necessary. Note that you’ll need to enclose the field & table names above with ` characters, the message board is erasing them in the example query string.

As MD Support said, if you’re doing any kind of work or maintenance with your DB, it’s well worth it to have PHPMyAdmin installed, even if you leave it disabled to reduce security risks and only make it available when needed for tasks such as this.

1 Like

There are several options. You can install adminer. I would go to their website, download the file.

Change the name from adminer-4.8.1.php to adminer.php, install it in the root openemr directory, then you can access it by going to openemr/adminer.php.

The other option is to install phpmyadmin outside of Openemr.

If you are looking for a report that you can access OpenEMR from the OpenEMR menu, that is something I can help you with. You will be able to download a pdf or a csv file.


False alarm.
My apologies to all who responded to my urgent request with suggestions and help.
I looked everywhere I thought would produce what I was looking for but didn’t find it.

After running into login problems with Adminer, (denies p/w logins to localhost) I went back into OpenEMR and looked again. Much to my chagrin (and relief), the system has the capability to produce exactly what I needed under Reports, Clients, List.

I’ll troubleshoot the Adminer login issue and put together a “how-to” in the near future.

Thanks everyone.

1 Like

One suggestion I’d make, regardless of the admin tools that you end up choosing to implement, (PMA, Adminer, etc).
Install them separately from your OpenEMR site, and require dedicated credentials to access those resources, maybe even disable them or make them unavailable when not actually in use.
This will reduce the attack surface and potential security risks, as any useful administrative tool is also a target for hackers.