MySQL Forums
Forum List  »  PHP

1 table, 3 fields, check True/False existence of 1 id therein
Posted by: Jeff Sabarese
Date: October 18, 2005 03:05AM

i decided to provide a link to a screen-shot of my 4 relational tables used in this app. this may help you to understand my description below. the table can be viewed here:
href=http://crowbar.psulionsden.com/crowbarRDB_sketch.htm

i'm using (i think!) a MySQL Subquery as a Scalar Operand syntax. as you will see below, i am checking 3 fields of one table using two subqueries within a MySQL SELECT query. i've encountered a mysql_error() which states that, because i have more than one result returned true,
******************
Warning: mysql_query() [function.mysql-query]: Unable to save result set in C:\Apache\...\artist_dates.php on line 16
Subquery returns more than 1 row
*******************
. so, although i'm narrowing down my problem as to how i am going to tell my user whether an Artist has any concerts scheduled, and since, if the Artist does have dates scheduled, the purpose of this script is to list the concert date, or dates, i was expecting to use that query to let the script proceed to the next section, which is to use WHILE arrays to list those dates. but, my script stalls because i am unable to store the multiple subquery results as i normally would as in $results = mysql_query($variable); where $variable in this case is my SELECT query and subqueries.

here's a chunk of the script so you can see how i'm trying to do it currently:
*******************
$checkinids = "select (select (select show_date from concerts where artist_id1=$artid)
show_date from concerts where artist_id2=$artid)
show_date from concerts where artist_id3=$artid";
$checkinres = mysql_query($checkinids, $conn) or die(mysql_error());
$checkinnum = mysql_num_rows($checkinres) or die(mysql_error());

if ($checkinnum == 0 ) {
$htmloutput = "<h1>Sorry, no Concerts Scheduled for $var2<h1>";

} else if ($checkinnum >= 1) {

function getdates() {
global $conn;
$seldates = "SELECT DATE_FORMAT(show_date, '%W, %M %D, %Y') AS formatted_date FROM concerts where artist_id1 =$_GET[var]";
$datesres = mysql_query($seldates, $conn) or die(mysql_error());
return $datesres;
}

******************
i hope you can see what i'm trying to do here. i figure that the problem can be solved more easily w/ the proper MySQL query as opposed to more skillful use of PHP code. perhaps it will require a little of both!

-- -- -- --
Use CSS [ content:" ?? " ] for Unicode + Control Chars (e.g. newline, etc)... Gain understanding of Codepage, Charset, Encoding, Keymapping... Generate CSS and JavaScript on-the-fly with PHP... Tales from the Communications Dept @ NoviceNotes.Net



Edited 2 time(s). Last edit at 12/09/2005 04:21PM by Jeff Sabarese.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.