php - postgresql: how to SELECT entries that satisfy a condition -


i trying select entries have same text in "email" column of postgresql table. completly new database , first database ever created, sorry if it's silly question. database has 3 columns: key, user_mails , json_adress. tried

$existent= "select *             (select public.account_recover_users.* keys,emails,jsons            public.account_recover_users)            emails='$email'"; 

but guess mistaking somewhere.

please help, trying learn , got bit stuck.

i writing answer, because accepted answer wrong in several respects. neither of 2 presented queries can work, though op incorrectly accepted answer.
original query couldn't work several reasons:

  • as mentioned (and error message states): subquery requires alias.

  • as mentioned, subquery pointless simple task.

  • this construct nonsense: public.account_recover_users.* keys can't apply alias after expanding * list of columns. postgres ignores it. might throw exception in future releases.

  • according description, existing columns named key, user_mails , json_adress (sic!). emails or jsons invalid references.

your absolutely basic query should be:

"select * public.account_recover_users emails = '$email'" 

you can rename columns in query appling column aliases, where clause cannot refer output columns (aliases), has refer input columns:

"select key, user_mails as email, json_adress as jsons    public.account_recover_users   user_mails = '$email'"

detailed explanation in related answer:
how re-use result select, , order clauses?


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -