Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Two Querys In One


How can I make this both querys be only one recordset?

select distinct grupo from sentient_campos where id_madre = 1

select distinct grupo_madre from sentien_campos where id_madre = 2




View Complete Forum Thread with Replies

Related Forum Messages:
Merging Two Querys
I have two query that I I would like to be one, but I can't figure out
how to do it. (mysql 3.23)

$sql = sprintf ("SELECT task,SUM(hours),login FROM activities WHERE
login='%s' group by login",$usuario);

$sql2 = sprintf ("SELECT SUM(hours) FROM activities WHERE login='%s'
AND month='%s' group by login",$usuario,$getdate);

View Replies !
Multiple Querys
I'm working on a query where I'd like to be able to search one OR two attributes. I've come accorss a few postings that lead me to the code below. It works fine if I put something in both attributes but fails if I leave the second blanc. Can you help?

SELECT * FROM books
WHERE title LIKE '%$title%'
AND title_sub LIKE '%$title_sub%'
ORDER_BY print_id


(p.s. I would lideally like to make the first attriubute optional. I may also want to add a few more attributes later)

View Replies !
Dates In Querys
I'm returning the month from a datatime stamp in a mysql query using the following:

MONTH(theDate) AS tMonth

Only problem is, if the month is before november, it doesnt not return the preceeding 0, so for example.. september I only get 9 not 09.

Is there any way in the query to define this?

View Replies !
Multiple Querys Into One
How can I reduce multiple querys into 1 I have 1 main select

PHP

//get all the booking data from the tables, now I need to
$cust_sql = mysql_query("SELECT DISTINCT
customer.bid,
customer.oid,
customer.c_name,
customer.pnumber,
customer.mnumber,
customer.party_names,
customer.paid,
booking.startdate,
booking.enddate,
booking.cid,
booking.resort,
booking.villa,
booking.vtype,
booking.adults,
booking.children,
booking.infno,
booking.outfno,
booking.atime,
booking.cost
FROM customer,booking
WHERE customer.bid= '" . $_GET['id'] . "'
AND booking.id='" . $_GET['id'] . "'");

if (!$cust_sql)
        {
               echo 'An error has occured with the db and is detailed below:<br> ' . mysql_error();
               exit;
        }

$row = mysql_fetch_row($cust_sql);

I then run a another to return the country name using the booking.cid from the main result set.

PHP

$country_sql = mysql_query("SELECT DISTINCT country_name FROM country WHERE cid = '".$row[14]."'");

Is there a way to condense the 2 or more queries into the main one.

View Replies !
Mysql Shuts Down During Rapid Execution Of Querys
I am using version 4.0.12-nt of MySQL and when I hit the enter key
rapidly I can't connect to the database. The result is a message is
returned to me from mysql that says I can't connect because the
database is down. If I only hit the 'enter' key once (to execute the
page that my queries are on(their are four queries on this particular
web page)) my queries execute just fine.

We have noticed that this only happens when we:

View Replies !
20 Different Tables Querys Slowing Page Display
I have an issue with a very large PHP page that calls over 20 different MySql Statements. This page is loading somewhat slow and i want to speed things up. I have looked into sql caching applications like http://eaccelerator.net/ and http://www.danga.com/memcached/ which i may install later, but i feel they are more for pages that are called frequently, my page calls the same data less times but can call more than 2000 different versions of the data.

Being that my page is a little over 1000 lines, putting it all here is not gonna happen. I will try to shorten the code using examples... After writing the blow code.. it may be really confusing. I have stuck the file on my server http://www.empiresolutions.net/clien.../green_bar.zip in case anybody whats to get a better look. This file in it current state works fine, just is slow. Any and all help is so appreciated.

Another Question... Can anyone provide suggestions on how to bench-test my sql scripts to see exact improvment speeds?

Each indent means the following query is nested.

Query 1 (2 Join Tables)

Query 2 (2 Join Tables)

Query 3 (1 Table)

Query 4 (4 Join Tables, While Loop)

Query 5 (2 Join Tables)

Query 6 (1 Table)

Query 7 (4 Join Tables, While Loop)

Query 8 (2 Join Tables)

Query 9 (1 Table)

Query 10 (1 Table, While Loop)

Query 11 (2 Join Tables, Calls every 10 rows from Query 10)

Query 12 (2 Join Tables, Calls every 10 rows from Query 10, same as Query 11 basically)

Query 13 (2 Table, While Loop)

Query 14 (1 Table)

Query 15 (2 Join Tables, This query and subs are called 4 times in a FOR loop)

Query 16 (2 Join Tables)

Query 17 (2 Join Tables)

Query 18 (1 Table)

Query 19 (2 Join Tables)

Query 20 (1 Table)

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved