My SQL db has 2 tables, uidmap and gidmap each having 2 columns (UID,SID) and (GID,SID) respectively
Both the tables have single entry, as of now:
GID|SID
30000000|S-1-22-2
UID|SID
30000000|S-1-22-2
Here UID/GID are the primary key and SID also has UNIQUE constraint
I need to add entry into the tables , but first need to check if any such entry already exists
The problem I have that in a for loop, I need to do SELECT from the table where UID=<some-value> or GID=<some-value>
One way of doing is to first match which table we are querying into then match UID or GID
Is there a way to match the COLUMN values directly instead of names ?
Something of the type:
for table in TABLES:
SELECT * FROM table WHERE '%ID'=<some-value> and SID=<some-value>
Also have one additional query, whey do following fail:
SELECT * from gidmap where UID=<some-value>
Error: no such column: UID
While a "" around UID suppresses the no such column error:
SELECT * from gidmap where "UID"=30000000