SAE中使用MySQL查詢資料

2021-06-05 10:21:12 字數 443 閱讀 3873

sae中使用saemysql查詢資料

例如有一張表gamescore,查詢其中的前20名,並以csv的格式返回,可以用下面的**:

<?php

$mysql = new saemysql();

$sql = "select nickname,score from `gamescore` order by score desc limit 20";

$data = $mysql->getdata( $sql ); ?>

<?php foreach($data as $line): ?>

<?php echo $line['nickname'] ?>;<?php echo $line['score']."\n" ?>

<?php endforeach; ?>

<?php

$mysql->closedb();

?>

mysql 子查詢中 使用 limit

如果sql語句中的子查詢包含limit 例如 select from a where id in select id from b limit 3 會報錯 this version of mysql doesn t yet support limit in all any some subquery...

查詢中使用函式

常用的四類函式 字串函式,日期函式,數學函式,系統函式 1 字串函式 charindex 尋找乙個指定的字串在另乙個字串中的起始位置 select charindex name my name is tom 1 返回 4 備註 1表示開始查詢位置,可省略 len 返回傳遞的字串長度 select l...

MySQL在字段中使用select子查詢

前幾天看別人的 中看到在字段中使用select子查詢的方法,第一次見這種寫法,然後研究了一下,記錄下來 大概的形式是這樣的 select a select b.another field from b where a.id b.aid another field from a where 1 lim...