Re: [PHP] need help to build a query

2006-10-11 Thread Ivo F.A.C. Fokkema
On Tue, 10 Oct 2006 14:22:54 -0500, Richard Lynch wrote: > On Mon, October 9, 2006 2:58 pm, John Wells wrote: >> On 10/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >>> but I know there must be much better solution then this one. >> >> You're right: Simply JOIN your queries... >> >> SELECT ord

Re: [PHP] need help to build a query

2006-10-10 Thread John Wells
On 10/10/06, Richard Lynch <[EMAIL PROTECTED]> wrote: This is a lot more subtle problem than it seems at first glance, eh? Yup, sure is. Thanks for the detailed response, so helpful as always. -John W -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from so

Re: [PHP] need help to build a query

2006-10-10 Thread Richard Lynch
In MySQL, you can do "explain $query" to see what MySQL estimates will be the workload. Interpreting that output is more art than science, but with practice, you can at least avoid SOME querie that will drive your server to its knees. I did work on a PostgreSQL search engine once where we did a s

Re: [PHP] need help to build a query

2006-10-10 Thread afan
ok. got the point. > > > > On Mon, October 9, 2006 3:09 pm, [EMAIL PROTECTED] wrote: >> But, in this case I will have repeating order_date and order_status >> info? >> >> idorder_datestatusfile_name >> 122006-10-09live file1.jpg >> 122006-10-09live file2.jpg >

Re: [PHP] need help to build a query

2006-10-10 Thread afan
sure it is! ;) > On Mon, October 9, 2006 2:58 pm, John Wells wrote: >> On 10/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >>> but I know there must be much better solution then this one. >> >> You're right: Simply JOIN your queries... >> >> SELECT order_id, order_date, order_status, file_nam

Re: [PHP] need help to build a query

2006-10-10 Thread Richard Lynch
On Mon, October 9, 2006 3:09 pm, [EMAIL PROTECTED] wrote: > But, in this case I will have repeating order_date and order_status > info? > > idorder_datestatusfile_name > 122006-10-09live file1.jpg > 122006-10-09live file2.jpg > 122006-10-09live

Re: [PHP] need help to build a query

2006-10-10 Thread Richard Lynch
On Mon, October 9, 2006 2:58 pm, John Wells wrote: > On 10/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> but I know there must be much better solution then this one. > > You're right: Simply JOIN your queries... > > SELECT order_id, order_date, order_status, file_name > FROM orders >

Re: [PHP] need help to build a query

2006-10-10 Thread Richard Lynch
On Mon, October 9, 2006 2:44 pm, [EMAIL PROTECTED] wrote: > I have table orders with primary key order_id. I have table > uploaded_files > with primary key ufid and uploaded files are linked to orders by > order_id > column. > > I have to list all orders and uploaded files. this works fine: > > $qu

Re: [PHP] need help to build a query

2006-10-09 Thread Larry Garfield
On Monday 09 October 2006 16:50, John Wells wrote: > Yes you are right, but I guess you can decide which is worse: sending > extra data in one query or send extra queries. I guess it depends on > how many records we're talking about... It will vary with your problem, but in general, fewer queries

Re: [PHP] need help to build a query

2006-10-09 Thread John Wells
Yes you are right, but I guess you can decide which is worse: sending extra data in one query or send extra queries. I guess it depends on how many records we're talking about... Brad also brings up a good point I hadn't considered. I do think an OUTER join is possible, perhaps depending on you

Re: [PHP] need help to build a query

2006-10-09 Thread afan
while I was trying again I did something wrong (?) and my server is now "busy" and looks like it went down?!? The qestion is how can I check first query before I apply it to be sure I'm not goig to read every record in my DB or get into loop? thanks. -afan > On 10/9/06, [EMAIL PROTECTED] <[EMAI

Re: [PHP] need help to build a query

2006-10-09 Thread afan
But, in this case I will have repeating order_date and order_status info? idorder_datestatusfile_name 122006-10-09live file1.jpg 122006-10-09live file2.jpg 122006-10-09live file3.jpg 132006-10-09live file1.jpg 142006-10-09live

Re: [PHP] need help to build a query

2006-10-09 Thread Brad Bonkoski
[EMAIL PROTECTED] wrote: hi to all, I have table orders with primary key order_id. I have table uploaded_files with primary key ufid and uploaded files are linked to orders by order_id column. I have to list all orders and uploaded files. this works fine: $query = mysql_query(" select order_

Re: [PHP] need help to build a query

2006-10-09 Thread John Wells
On 10/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: but I know there must be much better solution then this one. You're right: Simply JOIN your queries... SELECT order_id, order_date, order_status, file_name FROM orders JOIN uploaded_files AS uf ON orders.order_id = uf.order_id O

[PHP] need help to build a query

2006-10-09 Thread afan
hi to all, I have table orders with primary key order_id. I have table uploaded_files with primary key ufid and uploaded files are linked to orders by order_id column. I have to list all orders and uploaded files. this works fine: $query = mysql_query(" select order_id, order_date, order_statu