开发者

Select from all tables with same start

开发者 https://www.devze.com 2023-02-25 19:21 出处:网络
How to select all tables who whas fs_ for example, its not a prefix, its a something added from me , but some tables has it, and i want to select all of them, not choasing the o开发者_运维技巧ne by on

How to select all tables who whas fs_ for example, its not a prefix, its a something added from me , but some tables has it, and i want to select all of them, not choasing the o开发者_运维技巧ne by one, but to select all tables who starts with fs_


in your MySQL database you can create an extra column that will contain such value. ex:

ID | NAME | DATE | FS_COLUMN  
1    jon    2011   1  
2    doe    2005   0  
3    tom    2001   1  


Then with PHP you can fetch these rows.

$q = mysql_query("SELECT * FROM table WHERE FS_COLUMN='1'");
$r = mysql_fetch_array($q);


$q = $dbc -> ("SELECT COUNT (*) fs_");

$q -> execute();

$count = $q -> rowCount();

echo $count;

It is hard to tell what you are asking or what you are trying to achieve!?

From what you have said try that, if not then please elaborate your question in a more clear and concise way.


well ... it's really no good design approach but to answer your question:

you will probably want to get all matching tables by

SELECT table_name  
FROM information_schema.tables
WHERE table_schema = '___YOUR_DB_NAME___' 
AND table_name LIKE 'fa\_%'

and construct your query based on the result

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号