0

I have alot of tables in database in one of this contains owner_id and another one have relation many to many with that,and that table have dissent_type how i can select dissent_type where owner_id = ""

Edited by blueman:-0: n/a

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by tesuji
0

Well, not sure whether you want to fetch all rows where owner_id contains empty string (where an instance physically exists in table) or where owner_id is NULL (that special value what indicates that instance does not physically exist in table) I state example for both, empty string and NULL value:

select dissent_type from thattable where owner_id = '' or owner_id IS NULL;

On the other hand, suffix _id of owner_id connotes someone that owner_id would be kind of primary key. If so, you should improve your table design for those rows you are looking for are orphans, in other words, referential integrity is destroyed.

Remark: "" (two double quotes) should not be used as string delimeters, use '' (two single quotation marks) instead. There are databases which report errors when mistaken these both different delimeters.

-- tesu

Edited by tesuji: n/a

0

select dissent_type from thattable where owner_id = "....."
but that give me
The specified field 'owner_id' could refer to more than one table listed in the FROM clause of your SQL statement

0

... could refer to more than one table listed in the FROM clause ...

Aha, I see!

You might be more precise, state a practical example, post in the concrete, possibly wrong sql select statement you are talking about, or even post your create-table DDLs you would like to get some pieces of advice.

btw, if it refers to various tables, you may have to use table joins.

-- tesu

Edited by tesuji: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.