Re: SQL: Limit 1 usage?
| From: | Ignatius Reilly | Date: | Thu, 30 Jan 2003 21:51:15 +0000 |
| Subject: | Re: SQL: Limit 1 usage? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-25275@lists.php.net to get a copy of this message | ||
Doubly wrong PHP syntax.
Try instead:
$sql = "SELECT * FROM accessnums WHERE areacode='{$_POST['areacode']}' and
city='{$_POST['cityselected']}' ORDER BY network LIMIT 1";
Ignatius
____________________________________________
----- Original Message -----
From: "jason wesley upton" <upton@bayou.com>
To: <php-db@lists.php.net>
Sent: Thursday, January 30, 2003 9:42 PM
Subject: [PHP-DB] SQL: Limit 1 usage?
> Currently I have a script that contains this piece of code:
>
>
> $sql = "SELECT MIN(network)
> AS 'network' FROM accessnums WHERE areacode='$_POST[areacode]' and
city='$_POST[cityselected]'";
>
>
> This works fine and accomplishes what I need. Some requirements changed
today and I now need to get more than just "network". In MySQL command line
I tried this:
>
> SELECT * FROM accessnums WHERE areacode="504" and city="New Orleans" ORDER
BY network LIMIT 1;
>
> This gives me the exact response I require. However, when plugging it
into my php code:
>
> $sql = "SELECT * FROM accessnums WHERE areacode=$_POST[areacode]' and
city='$_POST[cityselected]' ORDER BY network LIMIT 1";
>
> It can't execute the query. Any suggestions?
>
>
>
>
> Jason Wesley Upton - Web Design / Development - Application Development
> =====================================================
> Bayou
> Internet.........888.30.BAYOU............http://www.bayou.com
> =====================================================
> Tel: 318.338.2033 ICQ: 155895142 AIM: jasonwesleyupton Fax:
318.323.5053
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>