jac.kock Posted April 27, 2012 Share Posted April 27, 2012 hi all, is there a sql query that looks in every table for a given string? now i just do: $sql="select * from [the table] where name_desc like "'$string'" and del_tab='0'"; this search only that given tabel but is ther a query thats search trough the whole bd? thnx all for youre help jamie ( holland) Quote Link to comment https://forums.phpfreaks.com/topic/261690-how-to-search-the-whole-db/ Share on other sites More sharing options...
requinix Posted April 27, 2012 Share Posted April 27, 2012 No. And it wouldn't make sense for there to be one either. It'd be a nightmare to work with in the code too. How many tables are you talking about? What are they for? Quote Link to comment https://forums.phpfreaks.com/topic/261690-how-to-search-the-whole-db/#findComment-1341020 Share on other sites More sharing options...
jac.kock Posted April 27, 2012 Author Share Posted April 27, 2012 hi, its about 14 tables where i want to check if they are deletted bij there del_tab='1' to show in de cms so that i casn reset them if needed:) and the smallesd table has about 2300 items so thats why i want to search the whole bd butt if there is no code for it i must make one that search all bij there table names thnx jamie ( holland ) Quote Link to comment https://forums.phpfreaks.com/topic/261690-how-to-search-the-whole-db/#findComment-1341043 Share on other sites More sharing options...
awjudd Posted April 27, 2012 Share Posted April 27, 2012 In order to do what you want, you would have to first get a list of all of the tables in your database and then with that list, build a bunch of queries and run those off separately. That said, this is an absolutely horrible idea. This is going to be slow and completely defies the purpose of storing things in tables. If you need to search on something, then there should be a metadata table or something which all of these link to. ~awjudd Quote Link to comment https://forums.phpfreaks.com/topic/261690-how-to-search-the-whole-db/#findComment-1341048 Share on other sites More sharing options...
jac.kock Posted April 27, 2012 Author Share Posted April 27, 2012 hi, you mean something like an recycle bin as table that tels me where some is delete with tabel_name en item_id? well i think i could make that thanx for the help guy's Quote Link to comment https://forums.phpfreaks.com/topic/261690-how-to-search-the-whole-db/#findComment-1341211 Share on other sites More sharing options...
El Chupacodra Posted April 27, 2012 Share Posted April 27, 2012 I'm not sure exactly how you set up your tables and what the correlation is between them but there must be a much smarter way to do what you want to do. Instead of marking every table with del=1 you might be able to mark ONE of the table rows for deletion and join the other tables you need deleted. Quote Link to comment https://forums.phpfreaks.com/topic/261690-how-to-search-the-whole-db/#findComment-1341216 Share on other sites More sharing options...
cpd Posted April 27, 2012 Share Posted April 27, 2012 What your asking insinuates your using a flat file database instead of a relational database as you have the same data in different tables. This completely defies the rules of normalisation and goes against everything a relational database stands for. I would suggest you review your database structure before continuing as its the key in making your application work. Quote Link to comment https://forums.phpfreaks.com/topic/261690-how-to-search-the-whole-db/#findComment-1341248 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.