I HAVE A DATABASE : "NEWS"
IN "NEWS" HAVE A LOT OF "TABLE" : ABOUT 20 TABLE
IN EVERY TABLE HAVE 7 COLLUM : ID, TOPIC, MESSAGE, PICTURE, DATE, AUTHOR,DES
I WANT SEARCH ALL CONTENT OF TABLES.
PLEASE, HELP ME. THKS REGARDS
FIRST YOU DON'T NEED TO SCREAM, we can understand small letters.
Second, rethink your database design. There is no reason to use different tables if it have the same information, it will only cause troubles like this. Use one table instead of the 20 that you use now, then the task is simple.
ok sorry sir !
beacause every table is news EX: i have a database and tables:
NEWS | england-----content | | Italy---content | | Portygal ---content
So, i want search all contents in tables
Well, then use a column to mark what language it is. Easy to search, easy to insert, easy to add a new language and so on.
Oh !a Good ideal ! But my site has just finished. So i can not change struture my site and database. Mr can help me this problem....,please ! i used : Funtction "or" to connect SQl Selects . But it's hang up my server. ..hic hic Please....thks
I don't think there are any good way to solve this problem. I would suggest that you go back, redesign the database and programming and change it to be "correct". It will save you lots of trouble.
There is a MERGE engine in mysql that allows tables with identical columns and indexes to be combined and formed into a new table. This will not affect the structure of the underlying tables, it will just create a new table. Since the information in the merged table will only include info from inside the tables merged it will not have a language column. I don't know your exact situation or limitations so this may or may not be applicable.
ref: http://dev.mysql.com/doc/refman/5.1/en/merge-storage-engine.html
Using UNION to connect SELECT statements may also be an option
thk Piranha & Joepa so much ! i'll try it ! i hope do it !
Merging the existing tables into one could perhaps be done by altering each existing table to add a new column - "country" I guess from the examples, then setting the value for every row in each table to the appropriate country (so that's a single alter and a single update per table). Then merge the resulting tables.
give me your code ? please
Me? I don't have any code. It's your database.
i use phpmyadmin to control mydatabase. but i can not Union tables. please show me clearly , thks Mr
who used Search all tables like me ? give me your ideal ? tks 🙂)
UNION QUERY
To put them into a new table, do something like this:
create table all_news (language varchar(20), <column list>
where <column list> is the list of columns from the old tables.
insert into all_news select 'en', from news_english; insert into all_news select 'es', from news_spanish;
and so on.
I would avoid the merge handler if possible.
One question. Do all the different language tables have different character sets and collations for the different alphabets they use? That would be one reason for them, though unicode is supposed to solve that.