tags:

views:

146

answers:

4

I need to exclude first id entry, and display the rest on my wordpress, I have never used sql before.

$all_users_id = $wpdb->get_col( $wpdb->prepare("SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC", $sort ));
+1  A: 

I am not familiar with Wordpress, but try this:

$all_users_id = $wpdb->get_col( $wpdb->prepare("SELECT $wpdb->users.ID FROM $wpdb->users WHERE $wpdb->users.ID NOT IN (SELECT MIN($wpdb->users.ID) FROM $wpdb->users) ORDER BY %s ASC", $sort ));
RedFilter
It works great. Thank you.
bandanaZeroZero
+2  A: 

One way would be to use something like

SELECT  *
FROM    Table
WHERE   ID > (SELECT MIN(ID) FROM Table)
astander
+1  A: 
$all_users_id = $wpdb->get_col( $wpdb->prepare("SELECT `$wpdb->users.ID` FROM `$wpdb->users` WHERE `$wpdb->users.ID` != 1 ORDER BY %s ASC", $sort ));

The query used:

SELECT `$wpdb->users.ID`
FROM `$wpdb->users`
WHERE `$wpdb->users.ID` != 1
ORDER BY %s ASC

Fast and simple... Without sub-querys! :)

TiuTalk
This will only exclude ID #1, which is not necessarily the 'first' ID
Buckwad
A: 

If it's a mysql db then use the limit clause:

SELECT `$wpdb->users.ID`
FROM `$wpdb->users`
ORDER by $sort ASC
LIMIT 1,9999999

C.

symcbean