Add MYSQL constraint

Asked

Viewed 109 times

0

I am using the following query:

$sql = "SELECT * FROM `login` order by `account_id` ASC";

How do I add a constraint when account_id is 1 he "skip" and do not take the values of the line with account_id = 1?

1 answer

1


Say the ID can’t be 1:

$sql = "SELECT * FROM `login` WHERE account_id <> 1 order by `account_id` ASC";

Assuming that Ids are all positive, it can also be so:

$sql = "SELECT * FROM `login` WHERE account_id > 1 order by `account_id` ASC";
  • Perfect haha. I was trying to use php =! because I didn’t know the different symbol in MYSQL xD

  • 1

    Mysql also accepts != (as in PHP), but this would not work in other databases. Your attempt did not work because you reversed the order of characters!

  • Aaaaa now I understand. Thank you very much :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.