Mysql - How can I select rows based on two criterias

I'm trying to run this query, to select all the rows that have status = 1:

SELECT
acc.id,
acc.user_id,
acc.type,
acc.account,
acc.`status`,
acc.paid,
acc.`password`, CAST(AES_DECRYPT( BASE64_DECODE( `password` ), 'encryption-key') AS CHAR)
FROM acc

WHERE status = status = '1'

However, it returns all the tables, it does't select only the rows that have status = 1

It's probably a syntax error. I do need this

`acc.`password`, CAST(AES_DECRYPT( BASE64_DECODE( `password` ), 'encryption-key') AS CHAR)` 

part so I can decrypt the passwords.

What did I do wrong?

Upvotes: 0

Views: 39

Answers (1)

Prix
Prix

Reputation: 19528

  • You don't need to append acc. to all the fields given you're only retrieving data from one table.
  • You had and extra status attached to your condition

Should be:

SELECT `id`,
       `user_id`,
       `type`,
       `account`,
       `status`,
       `paid`,
       `password`, 
       CAST(AES_DECRYPT(BASE64_DECODE(`password`),'encryption-key') AS CHAR)
  FROM acc
 WHERE status = '1'

Upvotes: 1

Related Questions