php中查詢資料庫的selectin語句

時間 2022-02-03 17:25:20

1樓:

這麼寫當然不行,因為in裡面是個字串你放陣列格式就不對

用implode(",", $array)把陣列轉為字串就行,不用迴圈。

2樓:匿名使用者

php裡面也有where in 不可以寫陣列,要吧陣列轉換成字串

implode(",", $array)

3樓:匿名使用者

$abc 需要拼接為字串

<?php

$arr = array('1','2','3','4','5');

$abc = implode(",",$arr);

sql = "select * from table where id in($abc)"

?>

thinkphp 查詢語句 in 的相關問題

4樓:微禿中坑

你這裡的$where['depid']是一個陣列,array('in',$where)這裡的$where應該是個字串吧, 你把$where['depid']轉成字串再試試

php中mysql的查詢語句: a表中的查詢結果作為b表查詢的條件 這個select語句怎麼寫啊?

5樓:滬漂峰哥

select * from b where b表欄位 in (select a表欄位 from a)

其中in可根據需要用其他如like等替代

6樓:

select * from b where id in (select id from a)

在php中使用sql語句 怎麼取出查詢出來的最後一個資料?

7樓:千鋒教育

在php中使用sql語句可以通過倒序排列記錄取出第一條的記錄取到最後一條資料。

一般,php呼叫mysql的介面查詢,查詢語句如下:

select * from table order by id desc limit 1

這樣就取出記錄的最後一條記錄。

8樓:匿名使用者

倒排查出第一個或者count()你得到的結果 然後減1就是你最後一條的索引

9樓:聖鸞

select a.name name1,a.*,b.

value,b.* from piwik_site a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and b.

name='nb_visits' and a.idsite=b.idsite order by b.

value desc

如果頁面顯示的是這個語句,那麼最後一個應該是select a.name name1,a.*,b.value,b.* from piwik_site

a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and

b.name='nb_visits' and a.idsite=b.idsite order by b.value asc limit 1

或者先執行一次select count(*) 拿到數量num,再select a.name name1,a.*,b.value,b.* from piwik_site

a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and

b.name='nb_visits' and a.idsite=b.idsite order by b.value desc limit num-1,1

10樓:

queue 按id從大到小,取第一條

php 查詢mysql資料庫中 某個表裡面的某個值

把這條查詢語句改為 sql select gid,title,top,type,views,zcomnum,date from db prefix.blog order by date desc limit 5 改為。sql select gid,title,top,type,views,zcomn...

php中怎麼從資料庫中撒資料怎麼顯示最好有詳細

con mysql connect localhost root 資料庫資訊 mysql select db shop 資料庫名 mysql query set names utf8 設定字符集編碼 sql select goods name,goods number,shop price from...

php怎麼連線mysql資料庫,php怎麼連線Mysql資料庫問題!

db server localhost db user root db pwd password db name test sql select from user where username admin conn mysql pconnect db server,db user,db pwd m...