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.





Trying To Retrieve Most Recent Record Per Date


I have the following query which is retrieving a set of data it is
almost what I want but I can not manage to get the result I desire.

SELECT r1, r1_dev, r2, r2_dev, date, time
FROM output
WHERE output.id_modality = '1' AND output.id_linac='2'
ORDER BY output.date DESC

'r1','r1_dev','r2','r2_dev','date','time'
'37.500','0.334449476181','[NULL]','[NULL]','2006-07-27','15:00:00'
'50.000','0.334449476181','37.470','0.0000364374', '2006-07-27','11:26:00'
'50.000','0.334449476181','37.470','0.0000364374', '2006-07-27','11:26:00'
'40.812','0.8538683','0.000','0.0000000000','2006-05-12','08:50:00'
'41.580','2.7517359','40.370','-0.2383940000','2006-05-12','08:45:00'
'40.756','0.8155671','0.000','0.0000000000','2006-05-12','15:00:00'
'37.952','-0.472445','0.000','0.0000000000','2006-05-12','14:53:18'
'38.010','-0.3203424','0.000','0.0000000000','2006-05-12','14:52:33'
'39.488','3.3474615','37.916','-0.7667557000','2006-05-12','08:35:43'
'39.650','3.7714458','38.020','-0.4945683000','2006-05-12','08:22:38'
'40.330','-0.2382025','0.000','0.0000000000','2006-05-12','15:00:00'
'41.330','2.2354728','0.000','0.0000000000','2006-05-05','00:00:00'
'39.220','2.8528707','0.000','0.0000000000','2006-05-05','00:00:00'
'40.696','0.8814325','0.000','0.0000000000','2006-04-28','15:56:00'
'41.000','1.635019','0.000','0.0000000000','2006-04-28','15:55:00'
'38.380','0.8642144','38.400','0.9167752000','2006 -04-28','15:56:10'
'37.970','-0.2132824','38.510','1.2058597000','2006-04-28','15:49:23'

From the set above I would like to retrieve the latest measurement per
date but if I try to group by date (like below) I always get the first
result instead of the latest result.

SELECT r1, r1_dev, r2, r2_dev, date, time
FROM output
WHERE output.id_modality = '1' AND output.id_linac='2'
GROUP BY output.date ASC
ORDER BY output.date DESC

'r1','r1_dev','r2','r2_dev','date','time'
'50.000','0.334449476181','37.470','0.0000364374', '2006-07-27','11:26:00'
'39.650','3.7714458','38.020','-0.4945683000','2006-05-12','08:22:38'
'39.220','2.8528707','0.000','0.0000000000','2006-05-05','00:00:00'
'37.970','-0.2132824','38.510','1.2058597000','2006-04-28','15:49:23'




View Complete Forum Thread with Replies

Related Forum Messages:
Retrieve Most Recent Rows
I have a simple table with four columns. ID (auto_increment), username, score, and date (unix timestamp). How could I, if possible, get the past 10 scores of each unique username? So if there were 15 different usernames, I would get 150 rows returned (assuming all of them had played 10+ games). Can this be done in a single query or do I need to run a query for each username?

View Replies !
Retrieve Most Recent Records From Database Sorted By String Value
I'm having a problem with a simple select query. I've got users
uploading data into a database. I want to do something that seems as if
it should be really simple, but it isn't so far.

Basically, I want to retrieve the latest 12 records from the table,
sorted by the date-time field (uploaddate) then by a varchar field
(name). Here's the SQL that I'm using:

select * from tblcontent
where filetypeid=1 and release='Y'
order by uploaddate desc, name limit 12;

And here's the table schema:

Field,Type,Null,Key,Default,Extra
ContentID,int(3),,PRI,NULL,auto_increment
Name,varchar(50),,,,
Filename,varchar(100),,,,
Thumbnail,varchar(100),,,,
FileTypeID,int(11),,,0,
UploadDate,datetime,,,0000-00-00 00:00:00,
Description,text,,,,
ContributorID,int(10) unsigned,,,0,
Release,enum('Y','N'),YES,,N,

The problem I'm running into is that while I am retrieving the most
recent 12 records, it's not sorting by the varchar field. Instead, the
'Name' field seems randomly sorted. If I change the sort order (name,
uploaddate desc), I don't get the records that I want.

This seems like it should be something very simple to do, but it's
driving me nuts and I really have no idea how to resolve the problem. Code:

View Replies !
Getting The Most Recent Record
Given a table that has the following fields:

create table WAGE_RATES(
EMPLOYEE_ID int unsigned references EMPLOYEES,
DATE date,
HOURLY float(5,2),
WEEKLY float(5,2),
OTHER float(5,2),
index(DATE)

View Replies !
Recent Record
Basically what i want to do is create an SQL string that searches the table for a specific userID, THEN finds the most recent record of the userID (according to my datetime field which is called transdate).

Im Using ASP to connect to a MySQL database.

i've looked all over the net trying to find out how, also i dont really know which forum this should be in (either mysql or asp?).20

View Replies !
Join/Select Only Most Recent Record
I have two tables. The first is a list of customers and the second is a list of sales invoices. I want to link the 2 tables but only select the newest/most recent invoice. There can be many invoices for a single customer.

Customer Table
CustomerID integer (primary key);
CustomerName char

Sales Table
SaleID integer (primary key)
CustomerID integer (key from customer table)
SalesDate Date
SalesAmount integer

Here is what I have so far:

select customertable.customername, salestable.salesdate, salesamount from customertable
inner join salestable on customertable.customerid = salestable.customerid

How can I return only a single record for each customer (the most recent/newest sale)?

View Replies !
Return Most Recent Record For A Group Of IDs
How do I return only the 1 most recent record from one table given a list of customer IDs from another? We're unfortunately running just MySQL 4.0

Pseudo code: show a list of distinct customer IDs for those customers that have a currentbalance of > $0, who had an order marked canceled in the last 7 days.

Given:

orders
- orders.customerID
- orders.status
- orders.updated (datetime)

billing
- billing.customerID
- billing.currentbalance
- billing.updated (datetime)

View Replies !
Query To Display A Record By Recent Time
Many users uploaded their files to my mysql table through php script,
my table having the details of uploading time, file name, & uploader name.

i need to find the recent uploaded file for all uploaders.

i tried with this query,

select file_name,uploded_by,MAX(date_time) from upload group by uploded_by;

it is giving the recent time, but it is not giving the latest file, it is showing first uploaded file.

View Replies !
Retrieve 1st Record
I'm trying to figure out how to create a select statement to retrieve a record from a set of records with the lowest primary key?

View Replies !
Retrieve Smallest Record From Mysql
I have the following in a mysql DB


ID Name Money
1 Kevin 20000
2 John 1000


is there a mysql query i can run that will Select the name of the person where money is the smallest value?

View Replies !
Most Recent Date.
I have a date_added field in the database. But I always want to get the rows that have themost recent date with time

('clk0h4tski156pgfgo4kth21b6', '', 'Place_Card_personalised', 'Z/X', 2, ད.00', 'chris', ��-05-20 10:37:07'),
('clk0h4tski156pgfgo4kth21b6', '', 'Day_Invitation', 'M', 2, ྊ.00', 'chris', ��-05-20 10:37:07'),
('clk0h4tski156pgfgo4kth21b6', '', 'Day_Invitation', 'M', 2, ྊ.00', 'chris', ��-05-20 10:36:37');
Will the following query do what I want it to do?

SELECT DISTINCT(date_added), SUM(price) FROM cartTemp WHERE `cart_id` = '$cart_id' AND `username` = '$username' GROUP BY price

View Replies !
ORDER BY :: Most Recent Date
I have dates recorded in my database for my website, in a var char in this format: 4/8/07, 4/21/07, 4/22/07, 4/10/07, etc. When I use order by to try to order by the most recent date, it doesn't work.

I even know why, and it's because it'll put 4/8/07 before 4/21/07 because there is no 0 before the 8, so it sorts it as 8 larger than 2, which it is. Is there any way to get around this, so it will order correctly?

View Replies !
Grouping Fields And Getting Most Recent Date
I have a table like:

table_id
table_foreign
table_datetime

I'd like to select the highest datetime for each foreign. So far I've tried something like this...

SELECT
*
FROM
table
GROUP BY
table_foreign
ORDER BY
table_datetime DESC

Unfortunately, the ordering only works on the grouped resultset, not that the values of the dates.

View Replies !
Max(date) Per KeyField - Get Most Recent Data
I have a large list of daily stats from various systems, i.e.

Table Stats
SystemID | tagID | dtStamp | Value
S001 : T100 : 2006-03-23 : 50
S001 : T101 : 2006-03-23 : 2
S001 : T100 : 2006-03-24 : 53
S001 : T101 : 2006-03-24 : 5
S001 : T100 : 2006-03-25 : 60
S001 : T101 : 2006-03-25 : 8
S001 : T100 : 2006-03-26 : 65
S001 : T101 : 2006-03-26 : 12
S002 : T100 : 2006-03-23 : 10
S002 : T101 : 2006-03-23 : 1
S002 : T100 : 2006-03-24 : 12
S002 : T101 : 2006-03-24 : 2

I need the date of the last record of data for each site for each tag. (i.e. the most recent data for each site)

I tried using max(dtStamp), but it found the biggest date in the table and tied it to every system/tag the same. i.e. it showed 2006-03-26 for S002/T101, even though I know I don't have data for that site on that day.

View Replies !
String Date, Selecting The Most Recent
Selecting the last 10 days subscriptions.

$Posted = date("F/d/Y, g:i:s");
$sql  = mysql_query("SELECT id FROM Subscribers WHERE activated='1' AND DATE_SUB(CURDATE(),INTERVAL 10 DAY) <= Subscribers.Posted");

If I turned Posted into a timestamp,it works.But I want to keep the date format as it is and still be able to perform that query.

View Replies !
Query To Retrieve 5 Records Immediately Before And After A Particular Record In Sorted Manner
Just consider a simple table with one integer column (however numbers are not inserted in sorted manner and some of them may be missing).

Given a particular record, say 32, I would like to retrieve 5 records immediately before and after this record in ascending manner of sort.

So, in this case I should get

25, 27, 28, 30, 31, 32, 33, 34, 37, 38, 39 (I did not have 26, 29 and 35 in the table)

Why do I go about writing such query?

View Replies !
Updaing Table For Records That Are More Recent Than Specific Date
I need to UPDATE a table

MySQL Code:
UPDATE exp_rating_stats SET form_name=my_new_form_name
WHERE rating_date > 2009-03-20 12:00 AM
How do I, when I already have a formatted date, convert so it can be interpreted correctly?

View Replies !
Automatically Record Date Of Record Entry
I have my database table set up and I have an HTML form that is PHP driven that will add the information entered into the form into to my database table.

I have a local buy-sell-trade Website. The way it has worked is that people fill out a form and the results emailed to me. I then take the information and enter it into a Web page. I only want the ads to be displayed for 30 days. I keep the ad for a total of 6 weeks (displays for 30 days and sits in limbo for 2 weeks afterwords) and if not renewed within that 2 week limbo period - I delete it.

Entering all the ads and keeping up with the dates manually has become a burden. I've only recently began looking into databases. My hosting company provides me with phpmyadmin and mysql 5.0. I'm new to all of this but I have managed to set up a database table and a HTML form that is PHP driven that allows ads to be automatically added to the database table.

There is a lot I need to do to make this ideal, but one step at a time.

First, I need to know the date (March 02, 2006) the ad was created or added to the database table. I know that I need to add some piece of code to my php form to record this information, but what code and where do I put it? I know I will need to create an extra field in my database table to house the date - I can handle this.

I've read the date and time information here http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

but there's a lot there and I don't know which is right for my needs. Plus, it doesn't tell me how or where to insert it into my php form (or does it?).

View Replies !
How To Retrieve Latest Date
I have a table that looks something like this:

table prop1 {
id;
addr;
zip;
name;
} (it's much larger than this)

And another table that looks like

table prop2 {
id;
price;
date;
}

The first table will have one entry per address. The second can have any number of entries with varying prices and dates. I need to retrieve the highest price with the latest date from prop2 for each entry in prop1.

I have tried this code:
select (p.id, p.addr, pp.id, pp.price, pp.date, MAX(pp.price) from prop1 p, prop2 pp where p.id = pp.id group by p.id order by p.addr);

This sort of does what I want. But it lists all of the results. So if one address has ten entries, all ten entries are returned. If I add a LIMIT 1, that works for the first address but no others are returned.

Is there a way to return just one entry for each address and have that entry be the one with the highest price and most recent date (or even just the highest price if need be)?

View Replies !
Retrieve Information Using Date Field?
I have a table called Event. In the table I have a date field. I want to Select specific fields and retrive events from the begining of this month to the end of february. In other words, 3 months span.

This is what I have,

SELECT EventDate, EventID, EventTitle, Event, DeptCode
FROM Events
WHERE DeptCode == '2'
ORDER BY EventDate ASC

Now my question is how do I ask for events in 3 monts span.

View Replies !
Retrieve The 'month' From Datatype Date
is there any function that allows me to retrieve a particular information, say, the month, from the datatype 'date'?

View Replies !
SQL Lastest Date Record
I have a table with records. Each record has these columns:

'id' PK
'note'
'matchid' FK
'date entered'

The table represents unique notes that are taken about person matches. For each match there could several notes.

I want to get only the latest record for each match (because i want only the latest notes).

How can I do this in SQL?

View Replies !
Selecting A Single Record According To Date
I have this SQL statement;

"SELECT * FROM event ORDER BY month ASC, date ASC";

But i'd only like to select the next one event in order of the date field. Instead of selecting them all. How can i order by the current date? The date and month are seperate fields.

View Replies !
Sorting By Latest Date Field In Each Record
I have a MySQL table with the following fields:

ID (int 11) (PK)
Company (varchar 50)
Contactdate (date)
Formdate (date)
Signdate (date)

I would like make a select query that orders the records by the most
recent date (i.e. descending) of any of the three date fields and then
by company name. Some date fields may be empty (null) A record must not
be listed more once.

For example, if I have the following data:

ID, Company, Contactdate, Formdate, Signdate
1, acme1, 2006-01-01, 2006-01-10, Null
2, acme2, 2006-01-01, 2006-01-11, 2006-01-12
3, acme3, 2006-01-08, 2006-01-09, 2006-01-09

The result should be:

2, acme2
1, acme1
3, acme3

In other words, the query should determine the 'latest date
field activity' of each record and then order by that date (and then by company).

If it is complicated to use null values I can also set the default
value of the date fields to something like '1900-01-01'.

View Replies !
SQL To Get Lastest Record Based On Date Of Entry
Here's my table:

Activity
- Id (PK)
- ProfileId (FK)
- Date

Each record represents a profile's activity in the CMS we're building (e.g. user updated profile, user uploaded photo, etc.) I'm only interested Id, ProfileId, and Date of the latest activity. How do I get that?

View Replies !
Select Record Based On 'change' Date
I currently have a database containing a table with the following fields:
signid, sign_typ, changedate and time.

The 'changedate' field is the date on which the star sign changes and becomes 'active' until the next 'changedate' in the table. I am trying to search this field by a date the user enters and display the 'sign_typ'.

View Replies !
Dont Display Record After Date Has Passed
Lets say I am making a site that has upcoming birthdays of a whole lot of people, and I want to display only the birthdays that have not happened yet (ie where birthday > current date).

What I do not know, is what format I must enter the date into; at the moment I am just using a char type in my MySQL database and entering it as : 26/03 (or what ever). Also, how would I get the current date and compare it to this date?

View Replies !
How To Check For Date/time Ranges Within Record (check For Schedule Conflicts)
You want to check scheduling conflicts and you have a record like:

appointments(table):
apptID
beginningDate
endingDate
beginningTime
endingTime

It's easy enough to check if a time is within that record. Say you want to
check if 8:00am to 10:00am is available, you would use this:

SELECT apptID
FROM appointments
WHERE (beginningDate = '2006-01-19' OR endingDate = '2006-01-19')
AND ('08:00:00' BETWEEN beginningTime AND endingTime
OR '10:00:00' BETWEEN beginningTime AND endingTime)

BUT, what if you have an all-day appointment (8:00am to 5:00pm) and there
exists an appointment already scheduled from 10:00am to 11:00am. The above
query would not find it.

Another question is what if the appointment is more than two days. Say, it's
from Monday - Wednesday from 8am to 5pm. The above query would not
successfully catch it if you wanted to schedule an appointment on Tuesday.

(I might be able to generate a date range using PHP, don't know if that's
the best way)

View Replies !
Most Recent Value
I've become rather rusty with the old SQL statements, and would really appreciate your help with the following.

Assume I have one table (tbldata):


dataID | date | configID | value
1 | 3 | 1 | 0.75
2 | 5 | 3 | 0.15
3 | 5 | 4 | 0.60
4 | 6 | 1 | 0.87
5 | 9 | 3 | 0.29
6 | 10 | 1 | 0.52

View Replies !
Sql To Get Most Recent Records
How would I write the query for mySQL to get all the records in a table that
were written in tha last 10 minutes?

I have a timestamp field (fldTime) that automatically inserts the curent
time when the record is inserted, but I'm unsure how to write a query that
would only get records from the last 10 miniutes.

View Replies !
Sort Asc W/ Most Recent
I want to display the five most recent rows in my table (there is a timestamp), but sorted in ascending order.

the problem is that when i call

SELECT * FROM spam ORDER BY time ASC LIMIT 5

it shows the first five entries in ascending order, but i want the last
five.

needless to say, it works fine with descending order..

View Replies !
Most Recent Entries
I have a table containing a "time" and an "author" column. How is it possible
to select the 10 most recent entries, but sorted by "author"?

View Replies !
Recent Entries
I have a table containing a "time" and an "author" column. How is it possible
to select the 10 most recent entries, but sorted by "author"?

View Replies !
1 Table -> Get Most Recent Row For Each Id
I have a problem that can be summarized with a simple table having the
following 3 columns:

timestamp
userid
status

The table is constantly being updated.

I'd like to get the most recent row for each userid present in the
table?

What pray tell is the trick?

I tried using GROUP BY, but it would only return the 1st occurance of
each userid (I want the last).

View Replies !
Recent Primary Key
I am trying to get my php page to select the most recent addition to a database under a certain username sorted by most recent primary key, but I am unsure on the SQL syntax to accomplish this. What I am trying to do is some thing like:
Code:
update table_name set title = new_title and content = new_content where username = username sort by primary key most recent;
Is this possible and if now do you have another idea of how I can accomplish something similar?

View Replies !
Updating Most Recent/last Row
This is for a directory and the table Dir holds the selected plan of each member. The table contains a history of the plans (inserted on each selection) so what I need to do is update the last row of Dir.DirID.

Every time 'Posting' value is echoed on the page with query 'Listings' (two seperate tables from Dir - one for runtime and one for the actual postings (a foreign/primary key) - then Dir.Dview is incremented as a basic hit counter with the query Listings higher on the page.

What is the most reliable way of updating the last row of Dir.DView where DirID is primary?

note: query 'Listings' uses SELECT max But experimenting with this before, I hessitate to use SELECT max for an update.

<?php echo ($row_Listings['Posting']);
$query_updateSQL = sprintf
("UPDATE Dir SET Dir.DView = (Dir.DView+1) WHERE DirID = %s",
$colname_Listings);
$result = mysql_query($query_updateSQL);
?>

View Replies !
Distinct, Most Recent Sort
Does anyone know how to do a sort to find the most recent distinct records.

We have records with equipment, and activities the equipment was used for,
but I need a distinct list of where the equipment currently is, if I do a
distinct ...order by date, it will perform the distinct first, ahead of
ordering.

View Replies !
Get Most Recent Version Of An Element
I'm new to mysql and I was wondering if I could trouble some of you for
help. I have a table in my database that may contain multiple versions
of the same element as different rows.

I wanted to use the following query to group the rows by element with
"group by" and then use the "having" to get the most recent version of
each element, which would then be returned in "select" but this doesn't
seem to be working. Any elements with multiple versions are simply not
returned.

I could swear that I have used a similar approach in the distant past
with other databases and it worked, though, so I must be bollocksing
this up pretty badly while attempting to work off of what I
remember...

View Replies !
Display 4 Most Recent Rows
I need to display the next 4 upcoming events (from the current date) in our events database...

SELECT * FROM events WHERE eventdate ??? LIMIT 4

View Replies !
Select Most Recent From A Group
Hello I am having troubles with a query I am trying to make.
I have a table to keep notes on customers
note_id - primary
biz_id
date_of_interest
notes

I want to grab the biz_id and notes of every record that has a date_of_interest before or on today's date. The problem I am having is if one customer has multiple notes such as:

3, 1233, 2006-05-02, note
8, 1233, 2006-06-28, note
13, 1233, 200-07-24, note

he will get selected from my query since two of his previous notes have a date_of_interest before today but I really only want to care about the most recent of notes so he shouldn't get selected. Is there a way to do this in the query or should I add another field to the database to mark it as the most recent.

View Replies !
Select, Order By. Most Recent One Last
I have one more question which is best explained by example. My database table contains a (very large) table with books and for simplicity sake lets assume every record only contains 2 fields:

Title and AuthorID ....

View Replies !
Way To View Recent Queries
Is there a way to view recent queries running on Mysql server (say last 3 minutes). In our application we faced, lock wait time out issue. I suspect some of the queries executed causes this issue.. If I check the queries that running on Mysql server, that may give a clue or may help to identify the issue.

View Replies !
Left Join To Get The 1 Most Recent
Firstly table structure - 1 user has multiple status records. When a new status record is created it gets the current datetime inserted into 'date_created'.

user
user_id
site_id

status
status
notes
date_created

I wish to display a list of all users and show beside them their current/most recent status record. Here is my code currently:

SELECT user.*, status.date_created, status.status, status.notes,
DATE_FORMAT(status.date_created,'%l:%i %p') as last_updated_time,
DATE_FORMAT(status.date_created,'%e/%c') as last_updated_date
FROM user
LEFT JOIN status ON status.user_id = user.user_id
WHERE user.site_id = 1
GROUP BY user.user_id
ORDER BY
CASE user.user_id WHEN 8 THEN 0 ELSE user.user_id END

Currently via the LEFT JOIN and GROUP this does display a list of all users with 1 status record per user but it's simply the first status record in the table (ordering by id i guess), not the most recent. How can I get it to display the most recent instead, based on date_created. I've tried adding ordering to the left join but this returned an error.

View Replies !
Showing 5 Most Recent Entries
I'd like an area on my site where the 5 most recent entries into the database are displayed in a list, with the top result being the most recent of all.

For this I was planning on doing something like querying the id field of the database to find the five highest numbers only and then echoing them out in descending order.

This however is not something I have been able to find any information on in my searches.

View Replies !
Group/Join - Wish To View Most Recent...
I've been trying to sort this out for over 2 hours and I can't get it to work! What I want is for the code at the base of this post to list each of the forums with the most recent topic details. My problem is that it doesn't choose the most recent post, it chooses the first.

I've tried:

- changing 'forums_topics.topic_time' to 'MAX(forums_topics.topic_time)' [returns the MAX value, but not the corresponding topic_id/title - it still returns the first topic_id/title!]

- adding 'forums_topics.topic_time DESC' to 'ORDER BY' [no effect]

- adding 'forums_topics.topic_time' to 'GROUP BY' [this lists them successfully, and with this the ORDER BY has an effect, but I don't want to list all topics, just the most recent]

- adding subqueries (couldn't get to work)

- adding 'HAVING topic_time = MAX(forums_topics.topic_time)' after 'GROUP BY forums_forums.forum_id' [which returns only the forums with a single post] .....

View Replies !
Displaying Only The Most Recent Added Files
Can someone please tell me how I can display only the most recent pdfs or Word documents that are added to a database?

View Replies !
Get GROUP To Display Most Recent Entry?
I'm pulling in info and Grouping by my column that stores "project names".
The Grouping is successful, but rather then displaying the most recent entry for the GROUP, the first entry made is displayed.

I would like the most recent entry to represent the group.

I would guess that this needs a MAX function run on my column that keeps the entry_date but I can't seem to get this to work.
Each time I apply the MAX function I end up limiting my results to 1 entry...not what I want.

This is the query I'm starting with:
MySQL
SELECT                              d.entry_id    as prj_id,d.field_id_1  as prj_name,d.field_id_5  as prj_thumb,d.field_id_15 as prj_image_type,d.weblog_id,t.entry_date,t.url_title as prj_url,t.status as prj_status,c.cat_url_titleFROM    exp_weblog_data dLEFT JOIN    exp_weblog_titles t    ON    d.entry_id =  t.entry_idLEFT JOIN    exp_category_posts cp    ON    t.entry_id = cp.entry_idLEFT JOIN    exp_categories c    ON    cp.cat_id =  c.cat_idWHERE    t.status = 'open'    AND    c.cat_url_title = '{segment_4}' // variable grabbed FROM URLGROUP BY    d.field_id_1ORDER BY    t.entry_date    ASCLIMIT 16

View Replies !
Getting Record Before Or After The Record That Meets The Criteria
In a query I want to get all the results and then order those results by last name, but then I want to filter those results down to only the record that comes before or after the record that has 'empno' = '1259'.

I want to get all the results already ordered and then filter them down to one record either before or after (depending on what is needed) the record where 'empno' = '1259'.

View Replies !

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