How to run a simple SELECT statement with two conditions?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
16 views
Good afternoon.
Stuck in a simple query
def get_referal(self, chat_id): with self.conn: self.cursor.execute('SELECT chat_id FROM profile WHERE ref = %s AND NOT comp_name IN ('No name');', (chat_id,)) return self.cursor.fetchall()

Gives the following error
psycopg2.ProgrammingError: column "No name" does not exist
LINE 1: ...rofile WHERE ref = 442965 AND comp_name NOT IN ("No name")...


Options
comp_name != "No name"
and
NOT comp_name IN ("No name")'
the same give the same error. Supposedly the field "No name" does not exist. Well, it's the value of a field, not the field itself...

Help me, tell me, what's blunt?
by | 16 views

2 Answers

0 like 0 dislike
All he asked the question, he decided.
Who cares, who will have the same error, you need to make the value of a field in a tuple
self.cursor.execute('SELECT chat_id FROM profile WHERE ref = %s AND comp_name != %s;', (chat_id, "No name"))
by
0 like 0 dislike
Use single quotes 'No name'
by

Related questions

0 like 0 dislike
6 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,534 users