PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Looking up a row of data based on amount and date
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Looking up a row of data based on amount and date

Réponse
 
LinkBack Outils de la discussion
Vieux 01/04/2008, 23h19   #1
larry@portcommodore.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Looking up a row of data based on amount and date

I'm trying to look up a value on a lookup table based on an amount and
a date

Now the "lookup-tables" change from period to period so the main
"tables" record has a start and end date and id

SELECT table_id FROM tables
$date >= startdate AND $date <= enddate

next I need to select the right row from the "tablelist" table (which
has all the lookup data) based on a column item that is the maximum
value but less than or equal to the amount


SELECT * FROM tablelist
WHERE table_id = $table_id
AND amount = SELECT MAX(amount) WHERE amount <= $testamount

I think I'm close, how would I roll it all into one?
  Réponse avec citation
Vieux 02/04/2008, 14h00   #2
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Looking up a row of data based on amount and date

On 1 Apr, 21:19, la...@portcommodore.com wrote:
> I'm trying to look up a value on a lookup table based on an amount and
> a date
>
> Now the "lookup-tables" change from period to period so the main
> "tables" record has a start and end date and id
>
> SELECT table_id FROM tables
> $date >= startdate AND $date <= enddate
>
> next I need to select the right row from the "tablelist" table (which
> has all the lookup data) based on a column item that is the maximum
> value but less than or equal to the amount
>
> SELECT * FROM tablelist
> WHERE table_id = $table_id
> AND amount = SELECT MAX(amount) WHERE amount <= $testamount
>
> I think I'm close, how would I roll it all into one?


Could you post some create table statements and some sample data in
the form of extended inserts with the expected output from said sample
data?
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h59.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07447 seconds with 10 queries