On Fri, Apr 11, 2008 at 4:01 PM, Victor Danilchenko
<[EMAIL PROTECTED]> wrote:
> Oooh, this looks evil. It seems like such a simple thing. I guess
> creating max(log_date) as a field, and then joining on it, is a solution --
> but my actual query (not the abridged version) is already half a
I just thought of something else... could the same be accomplished
using stored routines? I could find no way in MySQL to create stored
routines which could be used with the 'group by' queries though.
If this were possible, it should then be also possible to define a
'LAST' stored routine, o
On Fri, Apr 11, 2008 at 1:01 PM, Victor Danilchenko
<[EMAIL PROTECTED]> wrote:
> Oooh, this looks evil. It seems like such a simple thing. I guess
> creating max(log_date) as a field, and then joining on it, is a solution --
> but my actual query (not the abridged version) is already half a
Oooh, this looks evil. It seems like such a simple thing. I guess
creating max(log_date) as a field, and then joining on it, is a solution
-- but my actual query (not the abridged version) is already half a page
long.
I think at this point, unless someone else suggests a better solution,
th
On Fri, Apr 11, 2008 at 11:46 AM, Victor Danilchenko
<[EMAIL PROTECTED]> wrote:
> GROUP BY seems like an obvious choice; 'GROUP BY username', to be
> exact. However, this seems to produce not the last row's values, but ones
> from a random row in the group.
Under most databases your query i
Ah, that would work.
Looks like I was making the problem too complex in my mind, thanks for your
help.
Adam Bishop
-Original Message-
From: Dan Nelson [mailto:[EMAIL PROTECTED]
Sent: 22 January 2007 07:07
To: Adam Bishop
Cc: mysql@lists.mysql.com
Subject: Re: SQL Query Question
In the
In the last episode (Jan 22), Adam Bishop said:
> If I have a dataset as below:
>
> Name, Age, Word
>
> Bob, 13, bill
> Joe, 13, oxo
> Alex, 14, thing
> Jim, 14, blob
> Phil, 14, whatsit
> Ben, 15, doodah
> Rodney, 15, thingy
>
> I want to select the first block where
Right. If the employee ID in either the rep_no or entered_by columns does
not have a corresponding row in the global_employee table, then the regular
join won't match that row. In that case, as you found, you need a LEFT
JOIN, which guarantees you get the rows from the table on the left, and
Thanks a lot Michael.
A regular join did not seem to work. But when I tried a LEFT JOIN it worked.
A cut down example of it is the following.
SELECT global_lead.id, rep_no, es.fname as sales_name, em.fname as
marketing_name
FROM global_lead
LEFT JOIN global_employee es ON global_lead.rep_no = es.i
You need to join the employee table twice, once for each id lookup, like this:
SELECT es.name AS sales_name, em.name AS marketing_name, leads.id
FROM leads JOIN employee es ON leads.salesid = es.id
JOIN employee em ON leads.marketingid = em.id;
Michael
Michael J. Pawlowsky wrote:
I
If you do any math on your column, no index on the column can be used. If
possible, you should always try to write your condition so that the
calculations are done on the value(s) to compare to, not on the column. So,
assuming you have no rows with future timestamps, something like this should
The you will need to use the second format.
DATE_FORMAT(queue_time, '%Y%m%d') = CURRENT_DATE()
-Original Message-
From: Dirk Bremer (NISC)
To: [EMAIL PROTECTED]
Sent: 4/16/04 4:09 PM
Subject: Re: SQL Query Question
- Original Message -
From: "Victor Pendleton&quo
On Fri, 2004-04-16 at 14:09, Dirk Bremer (NISC) wrote:
> - Original Message -
> From: "Victor Pendleton" <[EMAIL PROTECTED]>
> To: "'Dirk Bremer (NISC) '" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Friday, April 16, 2004 15
- Original Message -
From: "Victor Pendleton" <[EMAIL PROTECTED]>
To: "'Dirk Bremer (NISC) '" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, April 16, 2004 15:57
Subject: RE: SQL Query Question
> If your data is stored in the
27;%Y%m%d') = CURRENT_DATE() + 0
...no index usage though
-Original Message-
From: Dirk Bremer (NISC)
To: [EMAIL PROTECTED]
Sent: 4/16/04 3:25 PM
Subject: Re: SQL Query Question
- Original Message -
From: "Victor Pendleton" <[EMAIL PROTECTED]>
To: "
- Original Message -
From: "Victor Pendleton" <[EMAIL PROTECTED]>
To: "'Dirk Bremer (NISC) '" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, April 16, 2004 15:06
Subject: RE: SQL Query Question
> WHERE queue_time = Now()
WHERE queue_time = Now() + 0
Are you wanting just the date or the datetime?
-Original Message-
From: Dirk Bremer (NISC)
To: [EMAIL PROTECTED]
Sent: 4/16/04 2:54 PM
Subject: SQL Query Question
I have a simple table where one of the columns is named queue_time and
is
defined as a timestamp-
This works for Oracle, give it a try, use any format you want for the MM/DD/YY area.
select to_char(queue_time, 'MM/DD/YY');
Scott Purcell
-Original Message-
From: Dirk Bremer (NISC) [mailto:[EMAIL PROTECTED]
Sent: Friday, April 16, 2004 2:55 PM
To: [EMAIL PROTECTED]
Subject: SQL Quer
I think I figured out the time problem. If I make s2 in the or s1 and
remove any instances of s2 it works very fast with the 'or'.
Joe
On Tuesday, January 20, 2004, at 09:50 AM, sulewski wrote:
Hello,
For my final solution I decided to use the inner join method. The
query is created dynamica
Hello,
For my final solution I decided to use the inner join method. The query
is created dynamically based upon a user interface component that
allows people to build queries using parenthesis, ands and or's. Plus
there is another field that I didn't include in the original question
so as to
Michael Satterwhite wrote:
On Monday 19 January 2004 16:30, Jochem van Dieten wrote:
Michael Satterwhite said:
On Monday 19 January 2004 15:38, Jochem van Dieten wrote:
So let's make it 2 fields:
SELECT
t1.*
FROM
table1 t1,
table2 t2 INNER JOIN table2 t3
ON (t2.rdid = t3.rdid AND t2.vid =
On Monday 19 January 2004 16:30, Jochem van Dieten wrote:
> Michael Satterwhite said:
> > On Monday 19 January 2004 15:38, Jochem van Dieten wrote:
> >> So let's make it 2 fields:
> >>
> >> SELECT
> >> t1.*
> >> FROM
> >> table1 t1,
> >> table2 t2 INNER JOIN table2 t3
> >>ON (t2.rdid = t3
Michael Satterwhite said:
> On Monday 19 January 2004 15:38, Jochem van Dieten wrote:
>> So let's make it 2 fields:
>>
>> SELECT
>> t1.*
>> FROM
>> table1 t1,
>> table2 t2 INNER JOIN table2 t3
>>ON (t2.rdid = t3.rdid AND t2.vid = 46 AND t3.vid = 554)
>> WHERE
>> t1.rdid = t2.rdid
>>
>>
On Monday 19 January 2004 15:38, Jochem van Dieten wrote:
> So let's make it 2 fields:
>
> SELECT
> t1.*
> FROM
> table1 t1,
> table2 t2 INNER JOIN table2 t3
>ON (t2.rdid = t3.rdid AND t2.vid = 46 AND t3.vid = 554)
> WHERE
> t1.rdid = t2.rdid
>
> Add GROUP BY/DISTINCT per your requireme
Lincoln Milner said:
> Or, if I'm not mistaken, you could do something like:
> SELECT t1.*
> FROM table1 t1, table2 t2
> WHERE t1.id = t2.rdid
>AND t2.vid IN (46, 554)
> ;
>
> That should work
No. You are back to square one where there should only be one record
in t2 with a vid of either 46
Jochem,
I believe this works. This is also easy to build dynamically. The query
is going to be generated based upon some user input. Thank you very
much,
Joe
On Monday, January 19, 2004, at 04:38 PM, Jochem van Dieten wrote:
Michael Satterwhite said:
On Monday 19 January 2004 13:17, sulewski
ssage-
From: Jochem van Dieten [mailto:[EMAIL PROTECTED]
Sent: Monday, January 19, 2004 4:39 PM
To: [EMAIL PROTECTED]
Subject: Re: SQL Query Question
Michael Satterwhite said:
> On Monday 19 January 2004 13:17, sulewski wrote:
>> Okay, I think I'm missing something obvious.
Michael Satterwhite said:
> On Monday 19 January 2004 13:17, sulewski wrote:
>> Okay, I think I'm missing something obvious. I have two tables
>>
>> Table 1 Table 2
>> ___ _
>> ID rdid vid
On Monday 19 January 2004 13:17, sulewski wrote:
> Okay, I think I'm missing something obvious. I have two tables
>
> Table 1 Table 2
> ___ _
> ID rdid vid
> ___ _
Let me post the question this way,
MyTable
---
pointerid valueid
811 54
811 63
812 100
813 200
814 300
815 400
I want all the records in MyTable w
try group by
SELECT firmal.beskrivelse as Businessline, lokasjon.navn as Location,
count(person.name) as "Sum People"
FROM
firmal INNER JOIN (
person INNER JOIN lokasjon
ON person.lokid = lokasjon.lokid)
ON firmal.firmalid = person.firmalid
group by firmal.beskrivelse, lokasjon.navn
-leo-
From:
So close, Thanks you very much Andy. I tried one similar to your suggestion, but
didn't get quite the result i expected.
Cheers
Paal
Ny versjon av Yahoo! Messenger
Nye ikoner og bakgrunner, webkamera med superkvalitet og dobbelt så morsom
Pael,
Try this:
SELECT firmal.beskrivelse as Businessline, lokasjon.navn as Location,
count(person.[uniqueid])
FROM firmal INNER JOIN (
person INNER JOIN lokasjon
ON person.lokid = lokasjon.lokid)
ON firmal.firmalid = person.firmalid
GROUP BY firmal.beskrivelse, lokasjon.navn
Replace [uniqueid]
Rolf,
You need to separate your functions. You are adding complexity to your
world by storing irrelvant infromation in your database. Critical Data
Handling (in a proper world) is ALWAYS handled separately from display. So
in your example,
You are storing all the html display formatting in your
Well, from what limited info I have, it looks like your image tag is not
closed properly.
Regards,
Mike Hillyer
www.vbmysql.com
> -Original Message-
> From: Rolf C [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 19, 2003 2:57 PM
> To: [EMAIL PROTECTED]
> Subject: SQL query question
>
ECTED]>; "MySQL" <[EMAIL PROTECTED]>
Sent: 28 March 2002 19:16
Subject: Re: SQL query question - using LIKE
> DL -
>
> Points well taken -
> I am using php and doing simple validation
> EX - if ($fname !="") {
> add fname string to search variabl
en me
enough to work with.
But I am certainly open for more suggestion/ feedback.
Thanks
Mark
-Original Message-
From: DL Neil <[EMAIL PROTECTED]>
To: Peter Lovatt <[EMAIL PROTECTED]>; Mark Stringham
<[EMAIL PROTECTED]>; MySQL <[EMAIL PROTECTED]>
Date: Thursday, Ma
Mark, Peter,
The query below assumes that the user will search of FirstName and none
or more of the other fields - which was not how the question reads (to
me).
To answer the question it would be useful to know how you are accessing
MySQL - are you using PHP (as per example code below) for examp
Hi
$query = 'SELECT *
FROM Table
WHERE
FirstName LIKE "%'.$firstname.'%"' ;
if($lastname)$query.= ', AND LastName LIKE "%'.$lastname.'%"';
if($region)$query.= ', AND Region LIKE "%'.$region.'%"';
if($loan_officer)$query.
It's not possible to do in one step in MySQL.
--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/
"roger westin" <[EMAIL PROTECTED]> wrote:
So a question
I have two tables. And i want to... (i just show you)
Table 1.
OwnerChar(30)Uniqe
FileChar
40 matches
Mail list logo