[PHP-DB] Re: Session Clean up?
If you are using a custom session handler by means of session_set_save_handler() - the last arg to the function is the gc() function, which is the actuall function that is used to clean up the expired sessions from the database. You would set the value in your php ini file unser the session gc directive from 0 - 100. If you set it to 0, the gc will never run and the expired sessions will hange around, if you set it to 100, the gc will run every time the session engine starts up ( every call to session_start() ). ~ Joe Penn "Allens" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, >A question on cleanup? > example: > 1. Connection via mysql_connect via the web. > 2. Know that mysql_connect relinquishes the connection link upon the > script ending. > 3. User performs work and has several global variables stored in memory > on the server. > 4. User doesn't logout at the end of the session, just quits the > browser. So session_destroy() and unset($user) aren't ran. > With that said, how does mysql clean up its cached globals for that > user? From a setting timing out in the php.ini file? If so, which > setting handles this? If not, does anyone know the process that mysql > goes through on the server side to clean up left over cached > variables? Thanks in advance. > :) >Gale L. Allen Jr >Macintosh Support Specialist >Phone: 919/412-5039 >Homepage: http://homepage.mac.com/ateam3/Menu5.html >iChat = [EMAIL PROTECTED] >"Remember, Love wins over all" > (: -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Session Clean up?
>A question on cleanup? > example: > 1. Connection via mysql_connect via the web. > 2. Know that mysql_connect relinquishes the connection link upon the > script ending. > 3. User performs work and has several global variables stored in memory > on the server. > 4. User doesn't logout at the end of the session, just quits the > browser. So session_destroy() and unset($user) aren't ran. > With that said, how does mysql clean up its cached globals for that > user? From a setting timing out in the php.ini file? If so, which > setting handles this? If not, does anyone know the process that mysql > goes through on the server side to clean up left over cached > variables? Thanks in advance. MySQL doesn't have cached variables. Neither does PHP, really. Session files are cleaned up based upon a php.ini setting, session.gc_maxlifetime, I think. Variables are destroyed when the script ends. Now, if you're storing your sessions in MySQL, then you must implement your own clean up. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help... PostgreSQL on Windows 98!
Hi: I can run postgres under win98 (SE) only with cygwin (only client not server) > Hi, > I'm trying to use PostgreSQL on Windows98! > Does anyone here succeded with it? > > Thanks > Bruno (sorry.. my mistakes). > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Session Clean up?
Hello, A question on cleanup? example: 1. Connection via mysql_connect via the web. 2. Know that mysql_connect relinquishes the connection link upon the script ending. 3. User performs work and has several global variables stored in memory on the server. 4. User doesn't logout at the end of the session, just quits the browser. So session_destroy() and unset($user) aren't ran. With that said, how does mysql clean up its cached globals for that user? From a setting timing out in the php.ini file? If so, which setting handles this? If not, does anyone know the process that mysql goes through on the server side to clean up left over cached variables? Thanks in advance. :) Gale L. Allen Jr Macintosh Support Specialist Phone: 919/412-5039 Homepage: http://homepage.mac.com/ateam3/Menu5.html iChat = [EMAIL PROTECTED] "Remember, Love wins over all" (:
RE: [PHP-DB] query and display acting weird...
As usual. John knows best. Thanks! Aaron -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: July 25, 2003 3:05 PM To: Aaron Wolski; [EMAIL PROTECTED] Subject: Re: [PHP-DB] query and display acting weird... Probably need: ORDER BY t.manufacturer, t.colourID ---John Holmes... - Original Message - From: "Aaron Wolski" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, July 25, 2003 2:58 PM Subject: [PHP-DB] query and display acting weird... > Hi Guys, > > Code: > > echo " style=\"font-family:monospace;\">\n"; > > $query = "select t.manufacturer, t.id, t.colour, t.colourID, t.type, > p.thread_index FROM kcs_threads t LEFT JOIN kcs_patternthreads p ON t.id > = p.thread_index WHERE p.pattern_index = '$id' OR p.pattern_index IS > NULL ORDER BY t.colourID"; > > $thread_manufacturer = ''; > > $result = db_query($query); > while($thread = db_fetch($result)) { > > if($thread_manufacturer != $thread['manufacturer']) { > echo " class=\"adminEditLink\">{$thread['manufacturer']}\n"; > $thread_manufacturer = $thread['manufacturer']; > } > } > > echo "\n"; > > In my select box I am getting results like: > > Canterbury Cross Fabrics > Zweigart > Permin > Zweigart > > I SHOULD be getting: > > Canterbury Cross Fabrics > Zweigart > Permin > > > This was once working.. as it should have but today more data was dumped > into the table which is causing the second Zweigart to be displayed. > > If I group the manufacturer in the query then I only one record > displayed for the corresponding manufacturers. > > Any clue how I can make it so that everything is sorted under grouped > manufacturers but still get ALL the results for the manufacturer at the > same time? > > Have over 4000 records which was causing a LONG loading time in the > browser so John Holmes gave me the above query to replace where I had 3 > queries doing the same thing. > > > ANY thoughts would be greatly welcomed! > > Thanks > > Aaron > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] query and display acting weird...
Probably need: ORDER BY t.manufacturer, t.colourID ---John Holmes... - Original Message - From: "Aaron Wolski" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, July 25, 2003 2:58 PM Subject: [PHP-DB] query and display acting weird... > Hi Guys, > > Code: > > echo " style=\"font-family:monospace;\">\n"; > > $query = "select t.manufacturer, t.id, t.colour, t.colourID, t.type, > p.thread_index FROM kcs_threads t LEFT JOIN kcs_patternthreads p ON t.id > = p.thread_index WHERE p.pattern_index = '$id' OR p.pattern_index IS > NULL ORDER BY t.colourID"; > > $thread_manufacturer = ''; > > $result = db_query($query); > while($thread = db_fetch($result)) { > > if($thread_manufacturer != $thread['manufacturer']) { > echo " class=\"adminEditLink\">{$thread['manufacturer']}\n"; > $thread_manufacturer = $thread['manufacturer']; > } > } > > echo "\n"; > > In my select box I am getting results like: > > Canterbury Cross Fabrics > Zweigart > Permin > Zweigart > > I SHOULD be getting: > > Canterbury Cross Fabrics > Zweigart > Permin > > > This was once working.. as it should have but today more data was dumped > into the table which is causing the second Zweigart to be displayed. > > If I group the manufacturer in the query then I only one record > displayed for the corresponding manufacturers. > > Any clue how I can make it so that everything is sorted under grouped > manufacturers but still get ALL the results for the manufacturer at the > same time? > > Have over 4000 records which was causing a LONG loading time in the > browser so John Holmes gave me the above query to replace where I had 3 > queries doing the same thing. > > > ANY thoughts would be greatly welcomed! > > Thanks > > Aaron > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] query and display acting weird...
Hi Guys, Code: echo "\n"; $query = "select t.manufacturer, t.id, t.colour, t.colourID, t.type, p.thread_index FROM kcs_threads t LEFT JOIN kcs_patternthreads p ON t.id = p.thread_index WHERE p.pattern_index = '$id' OR p.pattern_index IS NULL ORDER BY t.colourID"; $thread_manufacturer = ''; $result = db_query($query); while($thread = db_fetch($result)) { if($thread_manufacturer != $thread['manufacturer']) { echo "{$thread['manufacturer']}\n"; $thread_manufacturer = $thread['manufacturer']; } } echo "\n"; In my select box I am getting results like: Canterbury Cross Fabrics Zweigart Permin Zweigart I SHOULD be getting: Canterbury Cross Fabrics Zweigart Permin This was once working.. as it should have but today more data was dumped into the table which is causing the second Zweigart to be displayed. If I group the manufacturer in the query then I only one record displayed for the corresponding manufacturers. Any clue how I can make it so that everything is sorted under grouped manufacturers but still get ALL the results for the manufacturer at the same time? Have over 4000 records which was causing a LONG loading time in the browser so John Holmes gave me the above query to replace where I had 3 queries doing the same thing. ANY thoughts would be greatly welcomed! Thanks Aaron
Re: [PHP-DB] MYSQL and PHP cast() function...
I have tried the column as a varchar and timestamp but it does not work. with the Timestamp setup and DATE_FORMAT() I get 00-00- at the moment and I know that there are dates in there. The reason for this is the import changes all the field to 00 which is the TimeStamp default. I have also renamed the column to ReleaseDate in case there was a problem using a reserved word and there was still no fix. - Original Message - From: "CPT John W. Holmes" <[EMAIL PROTECTED]> To: "Morgan Bardon" <[EMAIL PROTECTED]>; "Moreno Riccardi" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, July 25, 2003 4:44 PM Subject: Re: [PHP-DB] MYSQL and PHP cast() function... > > Thanks for that, but I get a NULL entry in the field then for all the > dates. > > What column type is the DATE column? Also, since DATE is a reserved word in > MySQL, naming a column DATE probably wasn't a good idea. If you know you > always want the first 11 characters, you can always do LEFT(Date,11) to > retrieve them. DATE_FORMAT() will only work if your column is a date or time > column, i.e. DATE, DATETIME, or TIMESTAMP. > > ---John Holmes... > > > - Original Message - > > From: "Moreno Riccardi" <[EMAIL PROTECTED]> > > To: "Morgan Bardon" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > > Sent: Friday, July 25, 2003 4:34 PM > > Subject: R: [PHP-DB] MYSQL and PHP cast() function... > > > > > > > Try > > > $query2 = "select Title, date_format(Date,'%d-%m-%Y) as Date, Artist, > > > Country, > > > RecordCompany, CatalogueNumber, Composer FROM recording where title > regexp > > > '$keyword'"; > > > > > > Hi, > > > Moreno > > > -Messaggio originale- > > > Da: Morgan Bardon [mailto:[EMAIL PROTECTED] > > > Inviato: venerdì 25 luglio 2003 17.17 > > > A: [EMAIL PROTECTED] > > > Oggetto: [PHP-DB] MYSQL and PHP cast() function... > > > > > > > > > Hi there, > > > > > > I have been trying to get a solution to this select query from all over > > the > > > web and have found no answer so I was hoping someone here could help > out. > > > The date field of the database is imported from a text file with the > date > > > format 'dd-mm- hh:mm:ss' and I only want to display the first 11 > > > characters of the field. > > > > > > The select statment is am using is > > > $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, > Country, > > > RecordCompany, CatalogueNumber, Composer FROM recording where title > regexp > > > '$keyword'"; > > > > > > However when I try to use this I get an error about the cast function as > > > follows: > > > > > > You have an error in your SQL syntax near '(Date as varchar(11)) Date, > > > Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 > > > > > > Can anyone help me with the cast() function. I have gotten this to work > on > > > an internal MSSQL server but not on the MySQL server. > > > > > > thanks > > > > > > Morgan Bardon > > > > > > > > > > > > > > > > > > -- > > > PHP Database Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] R: [PHP-DB] MYSQL and PHP cast() function...
There's a mistake try this: $query2 = "select Title, date_format(Date,'%d-%m-%Y') as fDate, Artist, Country, RecordCompany, CatalogueNumber, Composer FROM recording where title regexp '$keyword'"; -Messaggio originale- Da: Morgan Bardon [mailto:[EMAIL PROTECTED] Inviato: venerdì 25 luglio 2003 17.39 A: Moreno Riccardi; [EMAIL PROTECTED] Oggetto: Re: [PHP-DB] MYSQL and PHP cast() function... Thanks for that, but I get a NULL entry in the field then for all the dates. - Original Message - From: "Moreno Riccardi" <[EMAIL PROTECTED]> To: "Morgan Bardon" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, July 25, 2003 4:34 PM Subject: R: [PHP-DB] MYSQL and PHP cast() function... > Try > $query2 = "select Title, date_format(Date,'%d-%m-%Y) as Date, Artist, > Country, > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > '$keyword'"; > > Hi, > Moreno > -Messaggio originale- > Da: Morgan Bardon [mailto:[EMAIL PROTECTED] > Inviato: venerdì 25 luglio 2003 17.17 > A: [EMAIL PROTECTED] > Oggetto: [PHP-DB] MYSQL and PHP cast() function... > > > Hi there, > > I have been trying to get a solution to this select query from all over the > web and have found no answer so I was hoping someone here could help out. > The date field of the database is imported from a text file with the date > format 'dd-mm- hh:mm:ss' and I only want to display the first 11 > characters of the field. > > The select statment is am using is > $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, Country, > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > '$keyword'"; > > However when I try to use this I get an error about the cast function as > follows: > > You have an error in your SQL syntax near '(Date as varchar(11)) Date, > Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 > > Can anyone help me with the cast() function. I have gotten this to work on > an internal MSSQL server but not on the MySQL server. > > thanks > > Morgan Bardon > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MYSQL and PHP cast() function...
> Thanks for that, but I get a NULL entry in the field then for all the dates. What column type is the DATE column? Also, since DATE is a reserved word in MySQL, naming a column DATE probably wasn't a good idea. If you know you always want the first 11 characters, you can always do LEFT(Date,11) to retrieve them. DATE_FORMAT() will only work if your column is a date or time column, i.e. DATE, DATETIME, or TIMESTAMP. ---John Holmes... > - Original Message - > From: "Moreno Riccardi" <[EMAIL PROTECTED]> > To: "Morgan Bardon" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Friday, July 25, 2003 4:34 PM > Subject: R: [PHP-DB] MYSQL and PHP cast() function... > > > > Try > > $query2 = "select Title, date_format(Date,'%d-%m-%Y) as Date, Artist, > > Country, > > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > > '$keyword'"; > > > > Hi, > > Moreno > > -Messaggio originale- > > Da: Morgan Bardon [mailto:[EMAIL PROTECTED] > > Inviato: venerdì 25 luglio 2003 17.17 > > A: [EMAIL PROTECTED] > > Oggetto: [PHP-DB] MYSQL and PHP cast() function... > > > > > > Hi there, > > > > I have been trying to get a solution to this select query from all over > the > > web and have found no answer so I was hoping someone here could help out. > > The date field of the database is imported from a text file with the date > > format 'dd-mm- hh:mm:ss' and I only want to display the first 11 > > characters of the field. > > > > The select statment is am using is > > $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, Country, > > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > > '$keyword'"; > > > > However when I try to use this I get an error about the cast function as > > follows: > > > > You have an error in your SQL syntax near '(Date as varchar(11)) Date, > > Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 > > > > Can anyone help me with the cast() function. I have gotten this to work on > > an internal MSSQL server but not on the MySQL server. > > > > thanks > > > > Morgan Bardon > > > > > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MYSQL and PHP cast() function...
Thanks for that, but I get a NULL entry in the field then for all the dates. - Original Message - From: "Moreno Riccardi" <[EMAIL PROTECTED]> To: "Morgan Bardon" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, July 25, 2003 4:34 PM Subject: R: [PHP-DB] MYSQL and PHP cast() function... > Try > $query2 = "select Title, date_format(Date,'%d-%m-%Y) as Date, Artist, > Country, > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > '$keyword'"; > > Hi, > Moreno > -Messaggio originale- > Da: Morgan Bardon [mailto:[EMAIL PROTECTED] > Inviato: venerdì 25 luglio 2003 17.17 > A: [EMAIL PROTECTED] > Oggetto: [PHP-DB] MYSQL and PHP cast() function... > > > Hi there, > > I have been trying to get a solution to this select query from all over the > web and have found no answer so I was hoping someone here could help out. > The date field of the database is imported from a text file with the date > format 'dd-mm- hh:mm:ss' and I only want to display the first 11 > characters of the field. > > The select statment is am using is > $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, Country, > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > '$keyword'"; > > However when I try to use this I get an error about the cast function as > follows: > > You have an error in your SQL syntax near '(Date as varchar(11)) Date, > Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 > > Can anyone help me with the cast() function. I have gotten this to work on > an internal MSSQL server but not on the MySQL server. > > thanks > > Morgan Bardon > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Do the included PHP MYSQL calls work with MYSQL 4
I have recently built PHP 4.3.2 using the --with-MySQL, but heard a rumor that the PHP built in libraries to MySQL are old and not completely compatible with MySQL 4. Does anyone out there know if this is not a concern...does the built in MySQL interface in PHP 4.3.2 work with MySQL or do I need to go another route. Thanks in advance... - Richard -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] R: [PHP-DB] MYSQL and PHP cast() function...
Try $query2 = "select Title, date_format(Date,'%d-%m-%Y) as Date, Artist, Country, RecordCompany, CatalogueNumber, Composer FROM recording where title regexp '$keyword'"; Hi, Moreno -Messaggio originale- Da: Morgan Bardon [mailto:[EMAIL PROTECTED] Inviato: venerdì 25 luglio 2003 17.17 A: [EMAIL PROTECTED] Oggetto: [PHP-DB] MYSQL and PHP cast() function... Hi there, I have been trying to get a solution to this select query from all over the web and have found no answer so I was hoping someone here could help out. The date field of the database is imported from a text file with the date format 'dd-mm- hh:mm:ss' and I only want to display the first 11 characters of the field. The select statment is am using is $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, Country, RecordCompany, CatalogueNumber, Composer FROM recording where title regexp '$keyword'"; However when I try to use this I get an error about the cast function as follows: You have an error in your SQL syntax near '(Date as varchar(11)) Date, Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 Can anyone help me with the cast() function. I have gotten this to work on an internal MSSQL server but not on the MySQL server. thanks Morgan Bardon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MYSQL and PHP cast() function...
Hi there, I have been trying to get a solution to this select query from all over the web and have found no answer so I was hoping someone here could help out. The date field of the database is imported from a text file with the date format 'dd-mm- hh:mm:ss' and I only want to display the first 11 characters of the field. The select statment is am using is $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, Country, RecordCompany, CatalogueNumber, Composer FROM recording where title regexp '$keyword'"; However when I try to use this I get an error about the cast function as follows: You have an error in your SQL syntax near '(Date as varchar(11)) Date, Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 Can anyone help me with the cast() function. I have gotten this to work on an internal MSSQL server but not on the MySQL server. thanks Morgan Bardon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] inputting datetime to mssql
Henrik, It's possible that the database is interpreting your date as a couple of subtraction operations. I always use quotes or single ticks around my dates when refrencing them in SQL. Example: INSERT into some_table (date) values ("2003-07-25"); Give a sample of your code so that your problem can be narrowed down. Ryan -Original Message- From: Henrik Hornemann [mailto:[EMAIL PROTECTED] Sent: Friday, July 25, 2003 9:18 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] inputting datetime to mssql Hi, I had this problem that was driving me crazy. I was trying to input a datetime to a mssql table, formated the same way as I use in all my other tables i.e d-m-Y. But no matter which variations of the basic format I tried, it didn't understand the date correctly. In desperation I tried something stupid, inverting the format to Y-m-d, which actually worked. My question is, how can this be possible that datetime fields in two tables in the same datebase requires the input date to be formated in different ways?? And is there any way to fix the odd one out? Regards Henrik Hornemann -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] inputting datetime to mssql
Hi, I had this problem that was driving me crazy. I was trying to input a datetime to a mssql table, formated the same way as I use in all my other tables i.e d-m-Y. But no matter which variations of the basic format I tried, it didn't understand the date correctly. In desperation I tried something stupid, inverting the format to Y-m-d, which actually worked. My question is, how can this be possible that datetime fields in two tables in the same datebase requires the input date to be formated in different ways?? And is there any way to fix the odd one out? Regards Henrik Hornemann -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] simple sql problem
Merlin wrote: Hello , I have a sql problem which seems to be simple, but I am kind of stuck, There are 2 tables with IDs. I would like to find out which ID from table one is not in table 2. My statement: SELECT ap. * FROM pictures p , album_pictures ap WHERE ap.pic_id != p.pic_id returns of course all the ids from table pictures which are not in table album_pictures, but I would like to have it the other way arround. So you want all IDs in album_pictures that are not in pictures? SELECT ap.id FROM album_pictures ap LEFT JOIN pictures p ON ap.id = p.id WHERE p.id IS NULL The people that "need" sub-selects for things like this need to learn some more SQL... but we're getting off topic. :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] simple sql problem
On Fri, 25 Jul 2003 02:31:39 -0600 Stephen March <[EMAIL PROTECTED]> wrote: > Any database that supports nested queries (unfortunatly this excludes > MySQL) ... you can do > Subselects are supported in MySQL 4.1 ... :-) > select pic_id from pictures where pic_id not in (select pic_id > from album_pictures) > If you are using a mysql earlier than 4.1, try following equivalent query... select pic_id from pictures left join album_pictures on pictures.pic_id= album_pictures.pic_id; Nested queries also called subselects are rarely required... Hence Mysql has not supported them until very recently. > > Otherwise you might have a harder time with MySQL ... something like Harder time?? depends on you background in databases engines. > set difference if it supports it (I'm not sure what it supports to > facilitate your need) > HTH > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] simple sql problem
Any database that supports nested queries (unfortunatly this excludes MySQL) ... you can do select pic_id from pictures where pic_id not in (select pic_id from album_pictures) Otherwise you might have a harder time with MySQL ... something like set difference if it supports it (I'm not sure what it supports to facilitate your need) HTH ~Steve Merlin wrote: Hello , I have a sql problem which seems to be simple, but I am kind of stuck, There are 2 tables with IDs. I would like to find out which ID from table one is not in table 2. My statement: SELECT ap. * FROM pictures p , album_pictures ap WHERE ap.pic_id != p.pic_id returns of course all the ids from table pictures which are not in table album_pictures, but I would like to have it the other way arround. Can anybody help on this. Thanx a lot in advance for any help, Merlin
[PHP-DB] simple sql problem
Hello , I have a sql problem which seems to be simple, but I am kind of stuck, There are 2 tables with IDs. I would like to find out which ID from table one is not in table 2. My statement: SELECT ap. * FROM pictures p , album_pictures ap WHERE ap.pic_id != p.pic_id returns of course all the ids from table pictures which are not in table album_pictures, but I would like to have it the other way arround. Can anybody help on this. Thanx a lot in advance for any help, Merlin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php