MYSQL 中的常見問題(包括資料篩選)

2021-07-11 02:45:12 字數 951 閱讀 4193

php無法返回漢字,返回相應的漢字資料時出現亂碼,這時只需要在**開始處加入相應的**。

php頁面為utf編碼 

header

("content-type: text/html; charset=utf-8");

php頁面為gbk編碼

header

("content-type: text/html; charset=gb2312");

php頁面為big5編碼

header

("content-type: text/html; charset=big5");

distinct關鍵字過濾掉多餘的重覆記錄只保留一條,但往往只用它來返回不重覆記錄的條數,而不是用它來返回不重記錄的所有值。

用count函式語句可以實現返回:

select *, count(distinct name) from table group by name

group by 必須放在 order by 和 limit之前,不然會報錯

示例**:

<?php

header("content-type: text/html; charset=utf-8");

$con = mysql_connect("localhost","root","huweishen");

if (!$con)

mysql_select_db("home_server", $con);

$result = mysql_query("select *,count(distinct device) from message group by device" );

while($row = mysql_fetch_array($result))

mysql_close($con);

?>

MySQL傳輸資料常見問題

timestamp 0 not null default current timestamp no zero in date 在嚴格模式,不接受月或日部分為0的日期。如果使用ignore選項,我們為類似的日期插入 0000 00 00 在非嚴格模式,可以接受該日期,但會生成警告。no zero da...

連線MySQL資料常見問題

錯誤資訊1 error 1045 28000 access denied for user usera localhost using password yes 錯誤資訊2 error 1045 28000 access denied for user usera localhost using p...

Mysql常見問題

1.安裝,推薦使用非安裝版.把解壓後的檔案拷貝到c盤根目錄下,並把總目錄改為mysql.然後進入windows命令 控制台,在c mysql bin下面執行mysqld nt install把它安裝為乙個服務,然後呼叫net start mysql啟動它,停止的命令是net stop mysql 想...