Broken query

I am trying to write a query to select a trivia question, but I don't want
the trivia question category to be the same two days in a row so I added a
second "SELECT" syntax to find out what category was used yesterday. This
works when I test it "live", but doesn't work when it is part of a cron
job. How do I get the value of `Bible_trivia_category_reference` from the
second SELECT query to be used in the first? What change is needed? Ron

SELECT * FROM `verse_of_the_day_Bible_trivia` WHERE `assigned_date` =
'0000-00-00' AND `seasonal_use` = $bible_trivia_application AND `live` =1
AND NOT `Bible_trivia_category_reference` = ( SELECT
`Bible_trivia_category_reference` FROM `verse_of_the_day_Bible_trivia`
WHERE `assigned_date` = '$last_mailing_date' LIMIT 1 ) ORDER BY RAND()
LIMIT 1


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
ron.piggott [ So, 11 Juli 2010 14:23 ] [ ID #2044313 ]

Re: Broken query

--00c09f9722e75b961b048b1bca56
Content-Type: text/plain; charset=ISO-8859-1

How is the last mailing date variable set?
Have you tried printing out the queries that are run when it is run manually
and when it is run as a cron to find any differences?

-patrick

On Jul 11, 2010 8:23 AM, "Ron Piggott" <ron.piggott [at] actsministries.org>
wrote:


I am trying to write a query to select a trivia question, but I don't want
the trivia question category to be the same two days in a row so I added a
second "SELECT" syntax to find out what category was used yesterday. This
works when I test it "live", but doesn't work when it is part of a cron
job. How do I get the value of `Bible_trivia_category_reference` from the
second SELECT query to be used in the first? What change is needed? Ron

SELECT * FROM `verse_of_the_day_Bible_trivia` WHERE `assigned_date` =
'0000-00-00' AND `seasonal_use` = $bible_trivia_application AND `live` =1
AND NOT `Bible_trivia_category_reference` = ( SELECT
`Bible_trivia_category_reference` FROM `verse_of_the_day_Bible_trivia`
WHERE `assigned_date` = '$last_mailing_date' LIMIT 1 ) ORDER BY RAND()
LIMIT 1


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--00c09f9722e75b961b048b1bca56--
Patrick Price [ So, 11 Juli 2010 14:29 ] [ ID #2044314 ]

Re: Broken query

Yes I have checked that $last_mailing_date contains a date.

I was wrong, It doesn't work when it is live. I had only ran the first
query before I added the "AND NOT" portion, sorry.

Ron

>
> I am trying to write a query to select a trivia question, but I don't want
> the trivia question category to be the same two days in a row so I added a
> second "SELECT" syntax to find out what category was used yesterday. This
> works when I test it "live", but doesn't work when it is part of a cron
> job. How do I get the value of `Bible_trivia_category_reference` from the
> second SELECT query to be used in the first? What change is needed? Ron
>
> SELECT * FROM `verse_of_the_day_Bible_trivia` WHERE `assigned_date` =
> '0000-00-00' AND `seasonal_use` = $bible_trivia_application AND `live` =1
> AND NOT `Bible_trivia_category_reference` = ( SELECT
> `Bible_trivia_category_reference` FROM `verse_of_the_day_Bible_trivia`
> WHERE `assigned_date` = '$last_mailing_date' LIMIT 1 ) ORDER BY RAND()
> LIMIT 1
>



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
ron.piggott [ So, 11 Juli 2010 15:05 ] [ ID #2044315 ]

Re: Broken query

>
> I am trying to write a query to select a trivia question, but I don't want
> the trivia question category to be the same two days in a row so I added a
> second "SELECT" syntax to find out what category was used yesterday. This
> works when I test it "live", but doesn't work when it is part of a cron
> job. How do I get the value of `Bible_trivia_category_reference` from the
> second SELECT query to be used in the first? What change is needed? Ron
>
> SELECT * FROM `verse_of_the_day_Bible_trivia` WHERE `assigned_date` =
> '0000-00-00' AND `seasonal_use` = $bible_trivia_application AND `live` =1
> AND NOT `Bible_trivia_category_reference` = ( SELECT
> `Bible_trivia_category_reference` FROM `verse_of_the_day_Bible_trivia`
> WHERE `assigned_date` = '$last_mailing_date' LIMIT 1 ) ORDER BY RAND()
> LIMIT 1

Try changing: "AND NOT `Bible_trivia_category_reference` = ( SELECT ..."
to "AND `Bible_trivia_category_reference` != ( SELECT ..."

>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--
Niel Archer
niel.archer (at) blueyonder.co.uk



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Niel Archer [ So, 11 Juli 2010 15:28 ] [ ID #2044316 ]
PHP » gmane.comp.php.database » Broken query

Vorheriges Thema: imagettftext
Nächstes Thema: Off Topic: Running Laptop/Desktop for a long time?