1

Trying to select data from a table whereby the where clause combines two fields to locate the specific data to be fetched. The code below does not work.

Select Email from users where FirstName || ' ' ||  LastName AS Nominative == 'fjpsojp 09809'
6
  • Any reason to not compare the first and last name separately like this SELECT Email FROM users WHERE FirstName = 'fjpsojp' AND LastName = '09809'? You could split the full name into parts in Python with something like this full_name.split(). Commented Feb 28, 2018 at 20:26
  • If your queries work when fed directly into SQL, you are probably having a problem with your double and single quotes with Python strings. Commented Feb 28, 2018 at 20:29
  • 1
    The query works without the AS part, not with it. Commented Feb 28, 2018 at 20:31
  • I should add, in the 'DB Browser for SQLite'. Commented Feb 28, 2018 at 20:32
  • What do you mean with "does not work"? Is there any error message? Commented Feb 28, 2018 at 20:34

1 Answer 1

3

If the fields Email, FirstName and LastName are in the Users table, then you can do your select like this:

select Email, FirstName || ' ' || LastName as Nominative 
from users 
where FirstName = 'fjpsojp'
and LastName = '09809';

This will give you results with two columns: one for Email, another for Nominative

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.