Re: SQL Syntax Help

2003-02-01 Thread Bob Hall
On Fri, Jan 31, 2003 at 02:07:11PM -, Kevin Smith wrote:
 Hi All,
 
 Can anyone help me get this query working in MySQL, this was created using
 Access, but it doesn't port well for MySQL syntax:
 
 SELECT b.id, p.part_code, p.product_type, p.description, po1.options,
 b.price, b.quantity, b.price*b.quantity AS total
 FROM (products AS p LEFT JOIN product_options AS po ON p.prod_id =
 po.prod_id) RIGHT JOIN (product_options AS po1 RIGHT JOIN (basket_header AS
 bh INNER JOIN basket AS b ON bh.basket_id = b.basket_id) ON po1.po_id =
 b.op_id) ON p.prod_id = b.prod_id
 GROUP BY b.id, p.part_code, p.product_type, p.description, po1.options,
 b.price, b.quantity, b.price*b.quantity, bh.basket_id, p.options
 HAVING (((bh.basket_id)=4));

Try
FROM (((basket_header AS bh INNER JOIN basket AS b 
ON bh.basket_id = b.basket_id)
LEFT JOIN product_options AS po1 
ON po1.po_id = b.op_id) 
LEFT JOIN products AS p 
ON p.prod_id = b.prod_id)
LEFT JOIN product_options AS po 
ON p.prod_id = po.prod_id

MySQL tends to be more finicky than Jet about how you group things.
I haven't tried this, but I think it will avoid confusing the MySQL 
optimizer.

Bob Hall

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: sql syntax help

2002-10-07 Thread Brent Baisley

You almost got it. Your syntax will be something like this:
UPDATE Table SET address=REPLACE(address,'#','Number') WHERE column 
like%#%

When I am trying to figure out the syntax for something, I always add a 
LIMIT 1 at the end so that only one record gets changed.

On Saturday, October 5, 2002, at 12:45 AM, Scott Johnson wrote:

 I have a db with slightly over 614,000 records of names and addresses.  
 In
 the address column, there are quite a few records like

 123 any rd # 2
 319 w. 1st st # B
 4321 test blvd # 42
 etc

 I want to replace all the number signs with the actual word 'number'.

 Is there a SQL command I can use for this or do I need the help of a
 scripting language (php or vb)?

 I was trying to construct something like update into table.column 
 select
 where column like '%#%' replace with '%number%'

 but of course that is not going to work.  I am a SQL newb btw.

 Any help appreciated.

 Thanks

 Scott

 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail mysql-unsubscribe-
 [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




re: sql syntax help

2002-10-07 Thread Victoria Reznichenko

Scott,
Saturday, October 05, 2002, 7:45:16 AM, you wrote:

SJ I have a db with slightly over 614,000 records of names and addresses.  In
SJ the address column, there are quite a few records like

SJ 123 any rd # 2
SJ 319 w. 1st st # B
SJ 4321 test blvd # 42
SJ etc

SJ I want to replace all the number signs with the actual word 'number'.

SJ Is there a SQL command I can use for this or do I need the help of a
SJ scripting language (php or vb)?

SJ I was trying to construct something like update into table.column select
SJ where column like '%#%' replace with '%number%'

SJ but of course that is not going to work.  I am a SQL newb btw.

Take a look at string function REPLACE():
 http://www.mysql.com/doc/en/String_functions.html


-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com





-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php