Solved

How to delete rows from tables starting with a prefix

Posted on 2014-07-24
1
458 Views
Last Modified: 2014-07-24
I have multiple tables all starting with the prefix of pfsense_

I would like to know how I can delete all rows from the tables starting with pfsense_ where column CUUID = blah
0
Comment
Question by:ITNC
1 Comment
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 40216821
You need to write a query that will write the final query for you.

select concat('delete from ' ,  table_name , ' Where CCUID = ''BLAH'';') from information_schema.tables where table_schema = 'MyDBName' and table_name like 'pfsense_%';

Open in new window


Paste the results of that query into a text editor to take off the | symbols.

then run that as your query.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 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