首先,向你介紹一下information_schema。
伊美網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站建設(shè)等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營維護(hù)。創(chuàng)新互聯(lián)公司2013年成立到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)。
information_schema這張數(shù)據(jù)表保存了MySQL服務(wù)器所有數(shù)據(jù)庫的信息。如數(shù)據(jù)庫名,數(shù)據(jù)庫的表,表欄的數(shù)據(jù)類型與訪問權(quán)限等。再簡單點(diǎn),這臺MySQL服務(wù)器上,到底有哪些數(shù)據(jù)庫、各個數(shù)據(jù)庫有哪些表,每張表的字段類型是什么,各個數(shù)據(jù)庫要什么權(quán)限才能訪問,等等信息都保存在information_schema表里面。
所以,你需要查表信息應(yīng)該去這個庫查
sql語句是
select * from information_schema.tables where table_schema='dbname';
希望采納,祝您愉快!
mysql
有一個默認(rèn)的數(shù)據(jù)庫,叫做information_schema
連上這個庫,執(zhí)行下面的語句(你自己那可能的改下下面的sql)
//table_schema
是你的數(shù)據(jù)庫名字
table_name是表名
select
*
from
tables
where
table_schema
=
'storage'
and
table_name
like
'product%'
你看看庫中這個表結(jié)構(gòu)就明白了,呵呵
這個簡單啊!首頁做個前臺輸入姓名和會員卡信息的頁面,我做個簡單的頁面給你看
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "html xmlns="headmeta http-equiv="Content-Type" content="text/html; charset=utf-8" /title會員查詢系統(tǒng)/title/head bodyform id="form1" name="form1" method="post" action="test.php" p label for="name"/label input type="text" name="name" id="name" / /p p label for="vipid"/label input type="text" name="vipid" id="vipid" / /p p input type="submit" name="button" id="button" value="查詢" / /p/form/body/html然后我給你一個test.php的文件代碼:?php$name = trim($_POST['name']);$vipid = trim($_POST['vipid']);$con = mysql_connect("127.0.0.1","數(shù)據(jù)庫用戶名","數(shù)據(jù)庫密碼");if (!$con) { die('Could not connect: ' . mysql_error()); }$a = mysql_select_db("數(shù)據(jù)庫名字", $con);$sql = "select * from kh_customer where name = '$name' and vipid = '$vipid'";$result = mysql_query($sql);while($row = mysql_fetch_array($result)) { echo $row['name'] . " " . $row['data']; echo "br /"; }mysql_close($con);?
你的表與表之間有沒有關(guān)聯(lián)?
如果有關(guān)聯(lián)的話,,可以寫成一個SQL語句
將查詢結(jié)果賦予一個數(shù)組
然后遍歷數(shù)據(jù)
將遍歷結(jié)果 賦在指定的位置中 就實(shí)現(xiàn)了你的功能
下面的代碼可以查詢單個數(shù)據(jù)庫的所有表的指定的字段內(nèi)容,如何才能實(shí)現(xiàn)多個數(shù)據(jù)庫一起查詢相同字段的內(nèi)容,每個數(shù)據(jù)庫字段都一樣,表都是100+個。并且下面的代碼雖然能查詢單個數(shù)據(jù)庫所有表的內(nèi)容,但是查詢一次耗費(fèi)時間很長,該怎么樣優(yōu)化才能加快速度,不然假設(shè)多個數(shù)據(jù)庫一起查詢實(shí)現(xiàn)了,該會變得多卡。
$i=1; //初始一個變量iwhile($i=100) //當(dāng)變量i小于等于100時都執(zhí)行{ $query ="select * from 表".$i." where 字段1=". $textfield; $row =mssql_query($query); $i++; //變量i遞增運(yùn)算//輸出查詢結(jié)果while($list=mssql_fetch_array($row)){ //print_r($list);echo '賬號:',$list['字段1'];echo '--〉昵稱:',$list['字段2'];echo '--〉密碼:',$list['字段3']; echo '/br';}} }
沒這么干過
mysql_list_tables
獲取
所有表信息
返回指針
mysql_tablename
獲取表名
myslq_num_rows函數(shù)來判斷結(jié)果指針中的表的數(shù)目
?php
mysql_connect("localhost",
"mysql_user",
"mysql_password");
$result
=
mysql_list_tables("mydb");
for
($i
=
0;
$i
mysql_num_rows($result);
$i++)
printf
("Table:
%s\n",
mysql_tablename($result,
$i));
mysql_free_result($result);
?
這是手冊上例子
后邊的不用我說了吧
sql查詢
網(wǎng)頁標(biāo)題:php查詢數(shù)據(jù)庫有什么表,php獲取數(shù)據(jù)庫的表的數(shù)據(jù)
網(wǎng)站URL:http://m.kartarina.com/article28/hddpcp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設(shè)、做網(wǎng)站、品牌網(wǎng)站設(shè)計、外貿(mào)網(wǎng)站建設(shè)、小程序開發(fā)、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)