This is a discussion on Check for statement within the MySQL Database forums, part of the Database Forums category; If I have a MySQL-query that seems like this: SELECT `dom`.`id`, `sam`.`id`, `fld`.`id` FROM `dom`, `fld`, `...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
If I have a MySQL-query that seems like this:
SELECT `dom`.`id`, `sam`.`id`, `fld`.`id` FROM `dom`, `fld`, `sam` WHERE `dom`.`id`='1', `sam`.`id`='6', `fld`.`id`='4'; Can I then count, if there is 3 returning values, or does anybody have a better idea to check, if there are 3 returning values? |
|
|||
|
>If I have a MySQL-query that seems like this:
>SELECT `dom`.`id`, `sam`.`id`, `fld`.`id` FROM `dom`, `fld`, `sam` >WHERE `dom`.`id`='1', `sam`.`id`='6', `fld`.`id`='4'; This query is wierd. You're doing a 3-way join with no relationship between the tables? >Can I then count, if there is 3 returning values, or does anybody have >a better idea to check, if there are 3 returning values? What interface are you using to submit queries (C, PHP, the mysql command-line utility, ODBC)? mysql_num_rows() (C, PHP interfaces) will tell you how many rows you got back. I don't see how you can possibly not get 3 values back in each row assuming you get rows back at all. NULL is a value. If you need to tell whether you got a NULL, that depends on the interface. |
|
|||
|
On 3 Mar., 18:54, gordonb.3g...@burditt.org (Gordon Burditt) wrote:
> >If I have a MySQL-query that seems like this: > >SELECT `dom`.`id`, `sam`.`id`, `fld`.`id` FROM `dom`, `fld`, `sam` > >WHERE `dom`.`id`='1', `sam`.`id`='6', `fld`.`id`='4'; > > This query is wierd. You're doing a 3-way join with no relationship > between the tables? What do you mean with relationship between tables? > >Can I then count, if there is 3 returning values, or does anybody have > >a better idea to check, if there are 3 returning values? > > What interface are you using to submit queries (C, PHP, the mysql > command-line utility, ODBC)? > > mysql_num_rows() (C, PHP interfaces) will tell you how many rows > you got back. I don't see how you can possibly not get 3 values > back in each row assuming you get rows back at all. NULL is a > value. If you need to tell whether you got a NULL, that depends > on the interface. It is on command-line NULL and an empty row should count |
|
|||
|
On 4 Mar., 21:22, "The87Boy" <the87...@gmail.com> wrote:
> On 3 Mar., 18:54, gordonb.3g...@burditt.org (Gordon Burditt) wrote: > > > >If I have a MySQL-query that seems like this: > > >SELECT `dom`.`id`, `sam`.`id`, `fld`.`id` FROM `dom`, `fld`, `sam` > > >WHERE `dom`.`id`='1', `sam`.`id`='6', `fld`.`id`='4'; > > > This query is wierd. You're doing a 3-way join with no relationship > > between the tables? > > What do you mean with relationship between tables? > > > >Can I then count, if there is 3 returning values, or does anybody have > > >a better idea to check, if there are 3 returning values? > > > What interface are you using to submit queries (C, PHP, the mysql > > command-line utility, ODBC)? > > > mysql_num_rows() (C, PHP interfaces) will tell you how many rows > > you got back. I don't see how you can possibly not get 3 values > > back in each row assuming you get rows back at all. NULL is a > > value. If you need to tell whether you got a NULL, that depends > > on the interface. > > It is on command-line > NULL and an empty row should count Oh, I mean shouldn't count as rows |