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.





How To Improve On A Nested Select


I'm working on a simple data import tool, and I need to insert email addresses from table two into table one, if they don't already exist in table one. I figured this was a pretty easy nested select statement, but what I'm doing is getting my site taken off line for exceeding the CPU limit. Here's the SQL I'm using to get the new email addresses:

SELECT distinct value, id FROM table_two WHERE name = 'email_address' AND value NOT IN (SELECT DISTINCT subscriber_email FROM table_one)

There are about 4600 rows in table one, and 145,000 rows in table two. Does this seem like it would be a burdensome query?

I'm not a SQL expert my any means, so is there a better way to go about this? It seemed like a simple one to me. Maybe my web host is just stingy with the CPU time.




View Complete Forum Thread with Replies

Related Forum Messages:
Improve SELECT Command
I perform a SELECT on my database, but it takes over a minute for every
run. I have to run it over 10000 times (with different values in the
WHERE), so it takes way too long. A was therefore wondering if I could
improve the query speed. Below you find the query. It is based on the
ratio between a pixel (pix) vs. the average of its neighbourhood (from
geo) in the same table (vgt) based on additional requirements
(mgba,mgsc,eco). Code:

View Replies !
Select Statement Question (nested Select?)
I have a DB containing 3 fields fullname, inext, and outext. I need to see all the records that have a duplicate entry in inext. I know I can do a distinct query on the inext column but that only gives me the unique ones I need all the different duplicate records.

View Replies !
Nested Select Using Like
I am trying to use the results of a nested select statement in the 'parent' statement using 'LIKE' as per:

SELECT * FROM t1 WHERE c1 LIKE (SELECT c7 FROM t2 WHERE ID = 987);

Does anyone know if this is possible? I am getting empty sets when I experiment with the placement of the % signs. For example:

SELECT * FROM t1 WHERE c1 LIKE "%(SELECT c7 FROM t2 WHERE ID = 987)%";
Empty set (0.01 sec)

Also I have tried to assign the result of the nested select to a variable like:
SELECT @v := c7 FROM t2 WHERE ID = 987;

But again then have no idea how to put this variable "@v" into a statement using LIKE.

Have tried:
SELECT * FROM t1 WHERE c1 LIKE '%@v%';
Empty set (0.00 sec)

View Replies !
Nested Select OR What To Use?
My table:
CatID, CatTitle, ParentID

Some example data:
1, Movies,0
2, Mymovies,1
3, Jaws, 2
4, Alien, 2
5, Predator,2
6, Final fantasy, 1
7, X-files,1

What i want in my output:
Movies (1), Mymovies (2), Jaws (3)
Movies (1), Mymovies (2), Alien (4)
Movies (1), Mymovies (2), Predator (5)

I want to use the output data to make a click-able tree level.
example:
Movies Mymovies Jaws
link?catid=1 link?catid=2 link?catid=3

View Replies !
My Nested SELECT
SELECT COUNT(1) as numapp
FROM post_jobs
(SELECT COUNT(pj.1) as numnot FROM post_jobs as pj WHERE member_id='m2e4m387' AND pj.approval = 0)
WHERE member_id = 'm2e4m387' AND approval != 0
I've looked stuff up online and have re-arranged this in several different ways. Can count not be used within a nested SELECT?



View Replies !
Nested SELECT :: Select All Years Except Last
I'm new to MySQL and want to do a nested SELECT statement. i want to get all years stored in the database except the last year: (content is the table and null values exists)

SELECT DISTINCT YEAR(content.date)
FROM content
WHERE(((YEAR(content.date)) IS NOT null)) AND YEAR(content.date) < (SELECT YEAR(MAX (content.date)) FROM content))
ORDER BY YEAR(content.date) DESC
What is wrong

View Replies !
Nested Select Statement
I am working on a feature for my website (MyRoladex.com) where i have a script run through the database once per hour, look to see who has events scheduled that are within the next hour, then look to see what their email/sms/text message preferences are, then email/text them a notification that it is close to time for their scheduled event.

Under the Accounts table, i have 5 notable fields: uid, email, mobile, timezone, messagetype

Under the DatebookEvents table, the important field is, eventdate (besides 'uid', obviously), which is is YYYY-MM-DD HH-mm-SS format.

I did not want to calculate the time zone difference for each user, and then compare it to each of the event dates, and then to the system time, just to see if a notification should be sent, as this would be an immense waste of cpu and bandwidth. The next best thing that i though of was to STORE the event date PLUS or MINUS the time zone difference, whenever the user creates a new event, and then, whenever the user displays their events, it would ADD or SUBTRACT the time zone to the event date, so that it will display correctly for them, AND when the cron job runs once every hour, it will ONLY have to compare the eventdate field with the system time. This is better because the cron job will run once per hour, and have to work with, perhaps, thousands of records, whereas a user may only display his records once or twice per day, thus saving cpu and bandwidth overhead

When i was writing the query for the displaying of event details, where i take the event date for the entry they are viewing and ADD or SUBTRACT their time zone to it so that it displays properly according to their time, i came across this problem:

Select eid,(eventdate + hour(select Accounts.timezone from Accounts where Accounts.uid='666')),left(note,40) from DatebookScheduler where uid='666'

Returns:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select Accounts.timezone from Accounts where Accounts.uid='666')),left(note,40) ' at line 1

View Replies !
Nested SELECT Statements
I am trying to form a query from a search form where users can search by various catergories. The version of MySQL I am using is 4.0.18 and doesn't seem to support nested select statements since it returns a syntax error at the point I try to use one. I can't use temporary tables or views as there are no permissions for create at the php page level. I really don't know what else to try as my SQL knowledge is not that vast. The query I have built so far is:

SELECT DISTINCT clientid, name
FROM (SELECT tbl_clientdetails.* , id, date_made from tbl_clientdetails, contact_made
WHERE tbl_clientdetails.clientid = contact_made.clientid) AS t1
WHERE id <> any (SELECT id from contact_made where date_sub(curdate(), interval 90 day)<= date_made)
AND name like '%boat%' OR industryType like '%boat%' OR comments like '%boat%' OR productBrand like '%boat%'

View Replies !
Using Update With Nested Select
I've got two tables.

wp_gameUsers & wp_achievements.

Each have a field called points, and I would like to be able to pull a selected record of points from wp_achievements and add it to a selected tally in wp_gameUsers.

Like so;

UPDATE wp_gameUsers SET points = points + (select points from wp_achievements where achieve_ID = 8 ) where id = 1

Except whenever i do this it updates the number twice,
Eg; 250 points from wp_achievements = 500 points..
The ID is unique I just can't figure out what is going on.

View Replies !
Nested Select On Same Table
I'm stuck with an SQL query.
i want to fetch 16 username and avatar from my table where 8 entries should follows one condition and remaining 8 follow another one.

more descriptively,

8 avatar- selected images by user.
8 avatar- default one.

View Replies !
Figure Out Nested SELECT Statements
I try to figure out how to use a nested "SELECT" statement after the
"IN" predicate. For example, when I try this code, it doesn't return
anything although it should:

SELECT book.IDLivre, aut.Prenom, aut.Nom FROM livre book, livreEcritPar
ecr, auteur aut WHERE ecr.IDLivre = book.IDLivre AND aut.IDAuteur =
ecr.IDAuteur AND book.IDLivre IN ("SELECT book.IDLivre FROM livre book,
livreEcritPar ecr, auteur aut WHERE aut.Prenom like '%$firstName%' AND
aut.Nom like '%$name%' AND ecr.IDAuteur = aut.IDAuteur AND book.IDLivre
= ecr.IDLivre");

So, my question is the following: How should I change syntax in order
to make this bunch of code work? I mean, under Oracle SQL, this syntax
would be legal and work perfectly, so I'm confused how to solve my
problem.

View Replies !
Syntax Error With Nested SELECT
Working with MySQL 4.0.27-standard via phpMyAdmin (and Perl)

I've been getting error #1064 for certain SQL statments, and have traced the problem down to nested SELECTs.

This works fine:

SELECT `CITY` FROM `pa_geotags` WHERE `PLACE_ID` = 1303 ;

Whereas this (just a trivial example to show the point):

SELECT `CITY` FROM `pa_geotags` WHERE `PLACE_ID` = (SELECT 1303) ;

gives rise to:

#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1303 ) LIMIT 0, 30' at line 1

I've tried several other (more complex) nested SELECTs, all give exactly the same type of error. phpMyAdmin seems to be non-optionally adding 'LIMIT 0, 30' to the end of my SQL before submitting it, but I don't think that's the problem; I sent the same SQL to the same database via a PERL script and also got a syntax error reported.

View Replies !
Insert With Nested Select Problem
I want to implement a query similar to this in mysql:

insert into table1 (field1)
(select t2.field2
from table2 t2
where t2.field3="string" and t2.field4=table1.field4)

the reference to table1 from the inner query (table1.field4) does not work.

Is there a way to achieve this?

View Replies !
Nested Select Statement Error
the mysql that is loaded on the host i am on is mySQL 4.0.24 whereas the one i am using is mySQL 5.0.27 on my computer.

i am having some weird problems where nested statements like this are not working on the server i am on...
select * from table1 where id = (select id from table2 where user = 1);

this sql statement works fine on my computer but not on the server. it says there is a syntax error when it is run on the server. but this sql doesn't look wrong to me, or it does?

i have a feeling that sub queries is not implemented in mysql 4.0 and earlier....but i really don't wish to change all the sql in my scripts to the old method where i have to select * from table1, table2 where table1.id = table2.user; because it will be quite troublesome...

View Replies !
SHOW TABLE STATUS & The Nested SELECT Statement
The "SHOW TABLE STATUS" command seems to return a result set, just
like "SELECT * FROM SomeTable".

Therefore, since the following is valid:

SELECT * FROM (SELECT * FROM SomeTable)

I inferred that this functionality would extend to the SHOW statement:

SELECT * FROM (SHOW TABLE STATUS FROM SomeDataBase)

But such a command gives an invalid syntax error. I want to query the data_length from a few tables, place those values into temp variables and then run a second SQL command using those
values. Is what I'm trying to do possible?

View Replies !
Nested Select Statement Taking Hours To Execute
I am running a sub select statment so I can compare a couple of tables. If I run the statement from two test tables of 1000 records in each, it will take nine seconds to get the results that I need.

However, if I take the same statement and point it to the two tables which contain all the data I need to run against (50560 and 161680 records respectively), it takes hours to run...how long I'm not sure. I fired the statement off yesterday afternoon @ 3pm and it is currently 11:30am the following day...the select statement is still executing.

Does anyone have performance on something like this?

View Replies !
Testing For An Empty Set Returned By A Nested Select Statement
For those of you following the "While Loop Within Select" thread... I've been restructuring my database to incorporate the changes. Now I've got a table of skipped stops rather than a table of stops (I need it that way for various reasons) and I need to return the schedule to the user as long as the user's stop isn't in the list of skipped stops. SO say something like:

SELECT
yada yada yada
FROM
schedule AS 's1'
WHERE
(
SELECT
skippedstop_id
FROM
skippedstops
WHERE
schedule_id=s1.schedule_id
AND
location_id=$origin
) == "EMPTY SET"

Only I have no idea how to actually test for the empty set from the nested select...

View Replies !
Nested Sets And Filtering Conversion To Nested Arrays, How?
I am currently working on a project where we want to reuse a tree structure stored in the database. The tree are basically groups/categories of all the content available within the project. Now we want to reuse this data in forum and only show the featured items/nodes.

An idea of the tree structure is:

+ root
+ Music (f)
+ Genre
- Electronic (f)
- Classical (f)
Now the problem is that we don't wan to show the whole tree structure within this new forum. But only the ones for example, which are flagged to be featured. For this, we have a field in the groups table. Only I happen to have some problems with reusing this tree hierarchy:

The main problem I have is that when I get the whole tree structure using the query SELECT * groups ORDER BY left_id then I have the whole tree.

Only when I add "WHERE featured=1" then the left and right node values are becoming invalid because I filtered out possible child or parent nodes.

I am curious if anyone could help me how to get the structure in such way I can easily reuse it. I would love to have the featured nodes in a nested array. Something like:

root
children: music
children: electronic, classical etc.

View Replies !
Insert Multiple Rows With One Insert Stmt And Nested Select
I'm trying to insert several rows into a table using only one insert statement:

insert into component_feature values (select 3,1,sf.software_feature_id,1 from software_feature sf where sf.software_id = 1)

When I run the select statement alone, I get the result I want:

+---+---+---------------------+---+
| 3 | 1 | software_feature_id | 1 |
+---+---+---------------------+---+
| 3 | 1 | 0 | 1 |
| 3 | 1 | 1 | 1 |
| 3 | 1 | 2 | 1 |
+---+---+---------------------+---+

But when I run the complete statement I get:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'select 3,1,sf.software_feature_id,1 from software_feature sf where sf.software_i' at line 1

This query is part of a PHP application I'm building. I'd rather not have to write a PHP loop to do multiple inserts.

View Replies !
Nested Select :: Checkboxes Checked / Not Checked
I'm trying to display a bunch of checkboxes in php and have them checked/not checked based on the results of the following query but I'm getting syntax errors. This would work in mssql how would I
accomplish the same thing in mysql?

SELECT tblOrg_Type.ID, tblOrg_Type.Org_Type, (Select 'Checked' from
tblContactOrgType where OrgID = 8 AND tblOrg_Type.ID =
tblContactOrgType.OrgTypeID ) AS Checked
FROM tblOrg_Type;

Table Structures:

tblOrg_Type
ID
Org_Type

tblContactOrgType
ID
OrgID
OrgTypeID

View Replies !
Improve Speed
I need to improve the speed of my ff sql statement but I do not know HOW! I am using mysql in running this. If the records are below a thousand, I have no problem getting the info quickly. But I tried it on 700,000 records, the feedback took 22 secs.In this sql statement, I am currenly accessing the same table but I have to get the rows of certain conditions multiplied to different numbers.

SELECT COUNT(IF(code='play',1,NULL))*5+count(IF(code like 'ok%',1,NULL))*2.50 + COUNT(IF(code='prev' OR code='prev_here',1,NULL))*15 + COUNT(IF(code='hello' OR code='hi',1,NULL))*15 + COUNT(IF(code='new',1,NULL))* 2.50 as sum from table;

View Replies !
Improve Sql Queries
i want to improve my sql queries, i am very poor in writing the queries so please tell me how to improve my writing of queries

View Replies !
Improve Query
I have this query that I use for stepping through records in a table, it selects for me the lowest, previous, next and highest record id refs for the table in question given the current record number.

However it returns its query on two rows with repeated (and obsolete) data due to the case statement, I pick out the data I require using mysql_result command in PHP, but it would be much nicer if there was a way to only return a one row result with only the data I require.

user_id is the autoinc field in table_t
$id is the current record number being viewed

PHP

SELECTmin(user_id) AS First,max(user_id) AS Last,    CASE when sign(user_id - '$id') > 0 then min(user_id) else max(user_id) end AS PrevNextFROM table_tWHERE user_id <> '$id'GROUP BY sign(user_id - '$id')ORDER BY sign(user_id - '$id')

for completeness my PHP code for extracting the values i need is

PHP

$first = mysql_result($result,0,0);$prev = mysql_result($result,0,2);$next = mysql_result($result,1,2);$last = mysql_result($result,1,1);

View Replies !
Improve Performance For InnoDB
Our database contains about 27,000 records only and it is very slow. Can someone please suggest any tips to increase the performance? We used InnoDB.

View Replies !
Improve The Execution Time
i am new to db2 want to ask questions about the performance of my sql commands for a view based another 3 views

the sql commnads are as following:

create view b_central_subgroup as
select communicator as central_member, project_id as project_id
from b_normalized_communicator
intersect
select initiator as central_member, project_id as project_id
from b_normalized_initiator
intersect
select monospeaker as central_member, project_id as project_id
from b_normalized_monospeaker

it takes 4.4 seconds to execute this sql.

it likes that the time is the summ of the other three views.

Can the execution time be reduced through some other methods?
If it is possible , then how ?

View Replies !
Best Way To Improve Performance On Order By?
I hope someone can help me with the following problem.

(Note: I will simplify my table structure to the essential)

I have two tables, one containing objects and one containing the objects a user has, so basically I have

* table_userObjects with PRIMARY KEY idUserObject INDEX ON idObject (not unique)
* table_objects with PRIMARY KEY idObject INDEX ON name

What I want to optimize is the query which gets the objects for one user and sorts them by name. For example:

SELECT *
FROM table_userObjects,table_objects
WHERE table_userObjects.idObject = table_objects.idObject
AND table_userObjects.idUser = 3
ORDER BY table_objects.name
LIMIT x,30

The db has around 40000 different objects and the top users have 200000 different items. In this cases it takes around 6 seconds to run the query. If I leave out the orderby no sorting has to be done and the query runs fast as expected.

Is there anyway to create an index on table_userObjects, based on the name of the objects from table_objects? Or some other way to speed up this query?

View Replies !
Indexes To Improve Performance
I am looking to add indexes to my database to try and improve performance. Now I heard someone say once that you should add an index to any column that you are planning to filter using in the where part of your statements.

So my question is this, in below is an example i have a table that I use to store reports that are generated by the system (i haven't chosen this especially but it has the core element that i user everywhere else). These core elements and columns that i regally in a where clause have '*' next to them. As such if i was following the advice of were to add indexes, i would probably add one to each of these columns.

Then there are the other three that have '+', which occasionally i conduct a '%%' (wildcard) search on to help me find a cretin report.

given this, plus the index on the primary key almost every table would have an index on it. To me this seems a bit much. So how many is too many?


View Replies !
How Do You Improve The Order By In Queries?
I read somewhere about mysql having to scan the table twice or something with "order by something"

this was on mysql.com (as far as I remember)

it said something about having it only have to scan it once but it didn't explain how to do it

I really want to know, because a 500k row table of mine with a few indexes that cut it down to about 90k per topic is lagging more than I want (okay, so 1.2 seconds average page load on a 8mb connection isn't too bad, but I want to fix this order by stuff and maybe make it 0.9 or 1.0 :P)

View Replies !
Index To Improve Queries With AVG()
Is there any way to create some sort of index that will improve the performance of queries which use the AVG() function. An EXPLAIN statement on the query indicates that no index is being used. There are indexes on the ratings table for ID and ratings but they don't seem to be getting used

EXPLAIN SELECT u.username AS username, ur.users_ID AS user_ID, IFNULL((AVG(r.rating))*(COUNT(ur.ratings_ID)),0) AS overall_score FROM ratings AS r, user_ratings AS ur, users AS u WHERE r.ID=ur.ratings_ID AND ur.active='yes' AND u.ID=ur.users_ID AND u.active='yes' GROUP BY ur.users_ID ORDER BY overall_score DESC LIMIT 0,40

id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE r ALL PRIMARY

5 Using temporary; Using filesort
1 SIMPLE ur ref rating,users_ID_2,active rating 4 v2.r.ID 239 Using where
1 SIMPLE u eq_ref PRIMARY,active PRIMARY 4 v2.ur.users_ID 1 Using where

View Replies !
How To Set An Index On Table To Improve The Performance
i've got a table with about 500 mio records. there are 3 col. decimal,decimal,int. my aim is to find data which fits best to the two decimal col.

in which way should i set the index for the best performance? at the moment my query needs sth about 5min and it shouldn't need longer than 10 sec. is it possible to improve the performance only by using the correct index.

View Replies !
How To Improve The Speed On Joining Tables
I have 2 tables, one of them has 0.8M of rows
the other has 40k of rows

total size is ~400MB

How can I improve the speed of joining these 2 tables faster?
do a sort first or other ways before joining them?

View Replies !
Limit Records To Improve Performance
I'm facing a performance issue, I'm using JDBC to read rows on a huge mySQL database 1.5 Million rows.

The programme basically read rows by sample of 1000 rows.

select * from <tbl_name> LIMIT i, i+1000

and print result in a text file.

This takes 5 minutes for the first 500000 rows, 10 min for the following 500000 and 18 for the rest. Which seems to me very slow just for reading rows?

I wonder 2 things:

1- is this normal for mySQL to take this time?
2- if not, is using LIMIT this way in the SQL would have an effect on mySQL performance?
2- how can I improve this performance.

If you think of anything that can improve the performance on a select * from , please let me know.

View Replies !
How To Improve The Speed Of Mysql Query Using Count(*)
I'm using this kind of queries in mysql in InnoDB engine

Select count(*) from marking1 where persondate between '2007-04-23 00:00:00.000' and '2007-04-23 23:59:59.999' and PersonName='aaa'

While executing these queries from front end VB, It takes above 5 secs with 50 thousand records.

How can I improve speed for this kind of queries. Is there any alternation for this command.

View Replies !
How To Improve MySQL Client Query Result Readability
I often use MySQL Command Line Client to query my database and i'd like to know if there is a way to improve the output readability of GROUP BY statements:

If I use the statement:

View Replies !
Nested SQL?
I'm atmysqlting to write a single SQL statement that will accomplish the following ...

View Replies !
Nested Sql
if nested select statement will work in mysql 3.23.53? i have a simple nested select statement which i believe no error on it.
here is my nested sql
SELECT
picid
FROM
picture
WHERE picid IN (SELECT picid FROM lightbox_image WHERE lbid =1)

View Replies !
Nested IF Statements
Basically i'm asking why doesn't this sql work? One If works fine but i'm not sure if you can nest them like this.. is there a better way?

This is narrowing down a products table by a variable being passed that is either subcategory, category or neither and then it narrows down by a brand if a brand is being passed.

SELECT *
FROM prodSubCat INNER JOIN (prods INNER JOIN prodCat ON prods.prodCatID = prodCat.prodCatID) ON prodSubCat.prodSubCatID = prods.prodSubCatID
WHERE (IF(subCatIDParam = 0,(IF(catIDParam = 0, prods.prodCatID LIKE '%',prods.prodCatID = catIDParam)), prods.prodSubCatID = subCatIDParam)) AND (IF(brandIDParam = 0,prods.prodBrandID LIKE '%',prods.prodBrandID = brandIDParam)

View Replies !
Nested Query
I have two tables one is called Targets and the other Leads:
Targets Fields: RecordID, TeamName, Manager, FebTGT
Leads Fields: RecordID, TeamName, DateLeadSubmitted, NewSale (value of NewSale defaults to 1)

Basically what I want to do is to show ALL the teams and their specific targets from the Targets table and then also show if they have made any leads between two dates - this info would come from the Leads table if they have made no leads I still want their info from the first table to be displayed.I have tried using a LEFT JOIN and this works fine until I have to apply the WHERE condition for the date parameters.

View Replies !
Nested SELECTS And SUM()
trying to calculate the amount owed by a customer:

SELECT c.compdirectdebit_number, SUM( (
cr.cramount + cr.crvat
) - (
SELECT SUM( cppaid ) AS paid
FROM companypaid cp
WHERE c.compcompanyid=cp.cpcompanyid) ) AS debit
FROM company c, companyreminder cr
WHERE c.compcompanyid = cr.crcompanyid
GROUP BY c.compcompanyid

I want to sum the amount+vat and then - the SUM of the payments which should give us the amount owed.

The nested select though is obvioulsy wong, but since this is the second time Ive used them, im struggling with the syntax.

View Replies !
Nested SQL Statement
I'm new to MySQL and I use this frequently with SQL Server 2000. I get an error and want to know if there is something equivalent with MySQL? Code:

View Replies !
DB Nested Tables
I am trying to make a database that has nested tables. how do i get foreign keys to relate to each other?

View Replies !
Nested Transactions
If a transaction is started in a stored procedure 'A' that calls stored procedure 'B' which has its own start transaction... commit statements, can 'A' rollback and undo the changes made by 'B' if it decides not to commit any longer?

View Replies !
Nested Condition?
I'm just getting trouble making a query that should be like this:

SELECT * FROM table where [cond1...] AND [cond2...] AND ([cond3...] OR [cond4]);

In fact I need to verify if certain value is in one column or another.

View Replies !
Nested Loop
I have searched thru the forum but didn't find anything that could help me.

I have a database with air dates of shows from different years. My query looks like this

$res=mysql_query("select DISTINCT * from performance ORDER BY showDate");


The db has the following fields:

showID
showDate
bandID
year
date

Here is the rest of the code:

$num=mysql_numrows($res);


while ($row = mysql_fetch_assoc($res)) {

if ($prev_show_val != $row['date']) {
//update the show date here so no dates repeat
$prev_show_val = $row['date'];
echo " ";
echo '<font face=arial size=4 color=#2F4F4F>' . $row['date']. '';
}
}


which successfully prints out only the unique airdates from the db.

What i want to do is have the year listed once for each set of airdates from that year so it would display 1975 once and then all the dates from 1975. Then 1976 would display once and all the dates from that year, etc.

View Replies !
Nested Tables
I have a situation where I have lots of users. I have a table that saves various information like the last time they logged in, the date they created their account, etc.
Each of these users also has data associated with them that would need a table. For example, if each user had their own ToDo list.
So my question is what is the best way to store that in a database? My first thought (coming from my programming background) is that I would add a column called todolist to the first table and that column would have a full nested table inside each cell that would store the list of ToDo items along with their priority and completion status, etc.
But I don't see any way to do that in mysql. So my second thought is to create table for each individual user called todolist_username.

Unfortunately that would give me potentially thousands of tables in my database. Is that the right way to do it or is there another option I'm unaware of?

View Replies !
Nested Functions
I know you can't use Nested GROUP BY Functions in MySQL, and I know you can't use SubQueries in MySQL ... so is there any substitute without having to resort to hardcode (i'm PHPing)?

View Replies !
Nested Loops
I have a data base table with fields for 'Town' and 'Title' among others. I need a bit of code that allows me to automatical output to screen a html link list. The problem is I need to only output the 'Town' field once and then all the 'Titles' that have the same town underneath. In a sort of sub menu way. eg: Code:

View Replies !
Nested Sql Count
I have two tables

survey
surveyID, title, memberID

responses
responseID, surveyID, date, status

I need to create a query where I can look at each survey and count the number of responses for each. The trouble is, each response has a status of "C" (complete), "P" (paused) and NULL (un finished) Code:

View Replies !

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