Re: Omit another where clause from original query

2017-09-20 Thread Hal.sz S.ndor
2017/09/19 17:19 ... Don Wieland: Of these found rows, I want to omit those rows where there are rows found after the END TimeStamp based on ?below ?where clause: WHERE 1 AND apt.appt_status_id IN (16) AND apt.user_id IN (3) AND apt.time_start > ‘1504238399' We are trying to fin

Omit another where clause from original query

2017-09-19 Thread Don Wieland
.last_name, c.last_name, c.first_name; /* end */ I want to add another condition: Of these found rows, I want to omit those rows where there are rows found after the END TimeStamp based on below where clause: WHERE 1 AND apt.appt_status_id IN (16) AND apt.user_id IN (3) AND apt.time_start > ‘15042383

Re: using alias in where clause

2016-01-29 Thread Larry Martell
gt;>>> IFNULL(f_tag_bottom_minor_axis, >>>>>>>> IFNULL(f_tag_ch_x_bottom, >>>>>>>>IFNULL(f_tag_ch_y_bottom, NULL) as ftag, >>>>>>>>STDDEV

Re: using alias in where clause

2016-01-29 Thread shawn l.green
h_x_bottom, f_tag_ch_y_bottom) as ftag, STDDEV(ch_x_top) As Johnny Withers points out, you may repeat the expression in the WHERE-clause: WHERE COALESCE(f_tag_bottom, f_tag_bottom_major_axis, f_tag_bottom_minor_axis, f_tag_ch_x_bottom, f_tag_ch_y_bottom) = 'E

Re: using alias in where clause

2016-01-28 Thread Larry Martell
FNULL(f_tag_ch_y_bottom, NULL) as ftag, >>>>>> STDDEV(ch_x_top) >>>>>> >>>>> >>>>> >>>>> >>>>> Of course, this isn't your real problem, but you could use COAL

Re: using alias in where clause

2016-01-28 Thread shawn l.green
may repeat the expression in the WHERE-clause: WHERE COALESCE(f_tag_bottom, f_tag_bottom_major_axis, f_tag_bottom_minor_axis, f_tag_ch_x_bottom, f_tag_ch_y_bottom) = 'E-CD7' If really only one of those is not NULL, it is equivalent to this: 'E-CD7' IN (f_tag_b

Re: using alias in where clause

2016-01-28 Thread Larry Martell
> SELECT COALESCE(f_tag_bottom, f_tag_bottom_major_axis, >>> f_tag_bottom_minor_axis, f_tag_ch_x_bottom, f_tag_ch_y_bottom) as ftag, >>> STDDEV(ch_x_top) >>> >>> >>> As Johnny Withers points out, you may repe

Re: using alias in where clause

2016-01-28 Thread shawn l.green
tag_bottom, f_tag_bottom_major_axis, f_tag_bottom_minor_axis, f_tag_ch_x_bottom, f_tag_ch_y_bottom) as ftag, STDDEV(ch_x_top) As Johnny Withers points out, you may repeat the expression in the WHERE-clause: WHERE COALESCE(f_tag_bottom, f_tag_bottom_

Re: using alias in where clause

2016-01-28 Thread Larry Martell
one): > SELECT COALESCE(f_tag_bottom, f_tag_bottom_major_axis, > f_tag_bottom_minor_axis, f_tag_ch_x_bottom, f_tag_ch_y_bottom) as ftag, > STDDEV(ch_x_top) > .... > > As Johnny Withers points out, you may repeat the expression in the > WHERE-clause

Re: using alias in where clause

2016-01-26 Thread Hal.sz S.ndor
STDDEV(ch_x_top) As Johnny Withers points out, you may repeat the expression in the WHERE-clause: WHERE COALESCE(f_tag_bottom, f_tag_bottom_major_axis, f_tag_bottom_minor_axis, f_tag_ch_x_bottom, f_tag_ch_y_bottom) = 'E-CD7' If really only one of those is not NULL,

Re: using alias in where clause

2016-01-25 Thread Johnny Withers
k for me, but I need to explore this more tomorrow. I need > the select to control the rows included in the aggregation. For > example, the rows where the f_tag_* col that is used does not = > 'E-CD7' should not be included in the aggregation. Also, I grossly > simplified the

Re: using alias in where clause

2016-01-25 Thread Larry Martell
g_* col that is used does not = 'E-CD7' should not be included in the aggregation. Also, I grossly simplified the query for this post. In reality I have 15 items in the where clause and a having as well. > Doing this any other way will prevent index usage and a full table scan will > be r

Re: using alias in where clause

2016-01-25 Thread Larry Martell
On Mon, Jan 25, 2016 at 8:01 PM, Rebecca Love wrote: > Have you tried using a select case statement for ftag? How would that help? Unless I'm missing something, I'd still have to have a reference to the column alias in the where clause. >> On Jan 25, 2016, at 6:39 PM, L

Re: using alias in where clause

2016-01-25 Thread Johnny Withers
this any other way will prevent index usage and a full table scan will be required. Is there a possibility of more than one column matching? How would you handle that? On Mon, Jan 25, 2016 at 6:16 PM, Larry Martell wrote: > I know I cannot use an alias in a where clause, but I am trying to &g

Re: using alias in where clause

2016-01-25 Thread Rebecca Love
Have you tried using a select case statement for ftag? > On Jan 25, 2016, at 6:39 PM, Larry Martell wrote: > > On Mon, Jan 25, 2016 at 7:27 PM, Reindl Harald wrote: >> >> >> Am 26.01.2016 um 01:16 schrieb Larry Martell: >>> >>> I know I ca

Re: using alias in where clause

2016-01-25 Thread Larry Martell
On Mon, Jan 25, 2016 at 7:27 PM, Reindl Harald wrote: > > > Am 26.01.2016 um 01:16 schrieb Larry Martell: >> >> I know I cannot use an alias in a where clause, but I am trying to >> figure out how to achieve what I need. >> >> If I could have an alias in a w

Re: using alias in where clause

2016-01-25 Thread Reindl Harald
Am 26.01.2016 um 01:16 schrieb Larry Martell: I know I cannot use an alias in a where clause, but I am trying to figure out how to achieve what I need. If I could have an alias in a where clause my sql would look like this: SELECT IFNULL(f_tag_bottom, IFNULL

using alias in where clause

2016-01-25 Thread Larry Martell
I know I cannot use an alias in a where clause, but I am trying to figure out how to achieve what I need. If I could have an alias in a where clause my sql would look like this: SELECT IFNULL(f_tag_bottom, IFNULL(f_tag_bottom_major_axis, IFNULL

Re: Unknown column 'users.users_id' in 'where clause'

2011-02-04 Thread Tompkins Neil
res_results > > WHERE (fixtures_results.away_users_id = *users.users_id*) > > > Any ideas why I'm getting Unknown column 'users.users_id' in 'where > clause' > > for the part of the statement that I've marked as *bold* and how I can > over > > come this pro

Re: Unknown column 'users.users_id' in 'where clause'

2011-02-03 Thread Simcha Younger
On Thu, 3 Feb 2011 13:55:36 + Tompkins Neil wrote: > SELECT DISTINCT(away_teams_id) AS teams_id > FROM fixtures_results > WHERE (fixtures_results.away_users_id = *users.users_id*) > Any ideas why I'm getting Unknown column 'users.users_id' in 'where clause&

Unknown column 'users.users_id' in 'where clause'

2011-02-03 Thread Tompkins Neil
y_teams_id = users_teams.teams_id) AND fixtures_results.status = 'approved' ORDER BY fixtures_results.last_changed ASC LIMIT 1) <> '' ORDER BY time_at_team ASC, time_registered ASC Any ideas why I'm getting Unknown column 'users.users_id' in 'where clause&#x

Re: Help with Date in Where Clause

2011-01-31 Thread Bruce Ferrell
On 01/31/2011 12:18 PM, Jørn Dahl-Stamnes wrote: > On Monday 31 January 2011 21:12, Phillip Baker wrote: > >> Greetings All, >> >> I am looking for a little help in setting a where clause. >> I have a dateAdded field that is a DATETIME field. >> I am look

Re: Help with Date in Where Clause

2011-01-31 Thread Shawn Green (MySQL)
On 1/31/2011 15:12, Phillip Baker wrote: Greetings All, I am looking for a little help in setting a where clause. I have a dateAdded field that is a DATETIME field. I am looking to pull records from Midnight to midnight the previous day. I thought just passing the date (without time) would get

Re: Help with Date in Where Clause

2011-01-31 Thread Phillip Baker
Thank you very much Jørn Blessed Be Phillip "Never ascribe to malice what can be explained by incompetence" -- Hanlon's Razor On Mon, Jan 31, 2011 at 1:18 PM, Jørn Dahl-Stamnes wrote: > Jørn

Re: Help with Date in Where Clause

2011-01-31 Thread Jørn Dahl-Stamnes
On Monday 31 January 2011 21:12, Phillip Baker wrote: > Greetings All, > > I am looking for a little help in setting a where clause. > I have a dateAdded field that is a DATETIME field. > I am looking to pull records from Midnight to midnight the previous day. > I thought jus

Help with Date in Where Clause

2011-01-31 Thread Phillip Baker
Greetings All, I am looking for a little help in setting a where clause. I have a dateAdded field that is a DATETIME field. I am looking to pull records from Midnight to midnight the previous day. I thought just passing the date (without time) would get it but I keep getting an empty record set

where clause

2011-01-02 Thread Elim PDT
I have a table with a column pv (int) I want to fetch all the rows r such that (r.pv)+1 is the pv-value of another row. what the sql looks like? thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...

Re: Error Unknown column in 'where clause'

2010-11-17 Thread Paul DuBois
eams_id > WHERE players_bids.bid_status = 'accepted' > AND players_bids.players_id = 279 > AND players_bids.worlds_id = 1 > ORDER BY players_bids.bid_type ASC, players_bids.bid_value DESC, > manager_points DESC, players_bids.bid_date ASC > > but the problem I have is that when referenci

Re: Error Unknown column in 'where clause'

2010-11-16 Thread Michael Dykman
ing players_bids.users_id_from >> within the UNION I get back the following error : >> >> Error Code: 1054 >> Unknown column 'players_bids.users_id_from' in 'where clause' >> >> Any ideas how to overcome this problem ? >> >> Chee

Error Unknown column in 'where clause'

2010-11-16 Thread Tompkins Neil
id = 1 ORDER BY players_bids.bid_type ASC, players_bids.bid_value DESC, manager_points DESC, players_bids.bid_date ASC but the problem I have is that when referencing players_bids.users_id_from within the UNION I get back the following error : Error Code: 1054 Unknown column 'players_bids.users_id_from' in &#x

RE: WHERE clause from AS result

2010-06-11 Thread Steven Staples
Putting the 'HAVING' in there, works perfectly :) THANKS! Steven Staples > -Original Message- > From: SHAWN L.GREEN [mailto:shawn.l.gr...@oracle.com] > Sent: June 10, 2010 8:03 PM > To: Steven Staples > Cc: 'MySql' > Subject: Re: WHERE clause fr

Re: WHERE clause from AS result

2010-06-10 Thread SHAWN L.GREEN
On 6/10/2010 4:38 PM, Steven Staples wrote: Ok, I have done it before, where I have used the AS result in an ORDER BY, but now, I can't figure out why I can't use it in a WHERE clause? SELECT `email`, (SELECT CONCAT(`phone_pref`, '-', `phone_suff`) FROM `pnums` WHERE `id`=

WHERE clause from AS result

2010-06-10 Thread Steven Staples
Ok, I have done it before, where I have used the AS result in an ORDER BY, but now, I can't figure out why I can't use it in a WHERE clause? SELECT `email`, (SELECT CONCAT(`phone_pref`, '-', `phone_suff`) FROM `pnums` WHERE `id`=`usertable`.`id`) AS pnum FROM `usertable` WHE

Re: WHERE clause from AS result

2010-06-10 Thread Keith Clark
You can use an Alias in ORDER BY but not in WHERE clauses. Keith On Thu, 2010-06-10 at 16:38 -0400, Steven Staples wrote: > Ok, I have done it before, where I have used the AS result in an ORDER BY, > but now, I can't figure out why I can't use it in a WHERE clause? > > S

Re: Join on a where clause.

2009-12-12 Thread Shawn Green
FROM event, mappings WHERE event.timestamp BETWEEN '2009-12-06 20:00' and '2009-12-07 20:00:00' AND event.src_ip BETWEEN 'mappings.start_ip' AND 'mappings.end_ip' GROUP BY event.src_ip ORDER BY count DESC LIMIT 20; Am I supposed to do a join somewhere? Do j

Re: Join on a where clause.

2009-12-11 Thread Joerg Bruehe
Hi Paul, all! Paul Halliday wrote: > On Wed, Dec 9, 2009 at 2:24 PM, Joerg Bruehe wrote: >> Hi everybody! >> >> >> Neil Aggarwal wrote: >>> Paul: >>> SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip), mappings.cc FROM event, mappings WHERE event.timestamp BETWEEN '2009-

Re: Join on a where clause.

2009-12-10 Thread Andy Wallace
A couple of thoughts - it's not "no quotes on integers", but "no quotes around column references". When you use 'mappings.end_ip', you are saying "the string mappings.end_ip", and not referring to a column in the mappings table. It just becomes a constant at that point. As for the performance, yo

Re: Join on a where clause.

2009-12-10 Thread Paul Halliday
On Wed, Dec 9, 2009 at 2:24 PM, Joerg Bruehe wrote: > Hi everybody! > > > Neil Aggarwal wrote: >> Paul: >> >>> SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip), >>> mappings.cc FROM event, mappings WHERE event.timestamp BETWEEN >>> '2009-12-06 20:00' and '2009-12-07 20:00:00' AND event

RE: Join on a where clause.

2009-12-09 Thread Neil Aggarwal
Joerg: > A matching column is called an "equijoin" > However, that is not mandatory / the only form. > As long as the problem can be solved using ranges (or multiple ranges) > which do not overlap, the join should solve it. I just learned something. Thanks for the info! Neil -- Neil Agg

Re: Join on a where clause.

2009-12-09 Thread Joerg Bruehe
Hi everybody! Neil Aggarwal wrote: > Paul: > >> SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip), >> mappings.cc FROM event, mappings WHERE event.timestamp BETWEEN >> '2009-12-06 20:00' and '2009-12-07 20:00:00' AND event.src_ip BETWEEN >> 'mappings.start_ip' AND 'mappings.end_ip' GR

RE: Join on a where clause.

2009-12-09 Thread Neil Aggarwal
Paul: > SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip), > mappings.cc FROM event, mappings WHERE event.timestamp BETWEEN > '2009-12-06 20:00' and '2009-12-07 20:00:00' AND event.src_ip BETWEEN > 'mappings.start_ip' AND 'mappings.end_ip' GROUP BY event.src_ip ORDER > BY count DESC LIM

Join on a where clause.

2009-12-09 Thread Paul Halliday
event.timestamp BETWEEN '2009-12-06 20:00' and '2009-12-07 20:00:00' AND event.src_ip BETWEEN 'mappings.start_ip' AND 'mappings.end_ip' GROUP BY event.src_ip ORDER BY count DESC LIMIT 20; Am I supposed to do a join somewhere? Do joins even apply in a where clause? o

Re: Prevent execution of queries without a WHERE clause

2009-09-08 Thread Ian Simpson
DATE and DELETE statments are allowed only if then include a WHERE > clause that spedifically identifies which records to update or delete > by means of a key,value or if they include a LIMIT clause. > 2. Output from single-table SELECT statments is restricted to no more > than 1,000 ro

Re: Prevent execution of queries without a WHERE clause

2009-09-08 Thread Darren Cassar
s are allowed only if then include a WHERE clause that spedifically identifies which records to update or delete by means of a key,value or if they include a LIMIT clause. 2. Output from single-table SELECT statments is restricted to no more than 1,000 rows unless the statment include a LIMIT cla

RE: Prevent execution of queries without a WHERE clause

2009-09-08 Thread Ian Simpson
> > > -Original Message- > From: Ian Simpson > Sent: Monday, September 07, 2009 5:14 PM > To: mysql@lists.mysql.com > Subject: Prevent execution of queries without a WHERE clause > > Hi all, > > I vaguely recall finding mention a MySQL command or start

RE: Prevent execution of queries without a WHERE clause

2009-09-07 Thread John Daisley
A) Certified MySQL 5 Developer Cognos BI Developer --- Sent from HP IPAQ mobile device. -Original Message- From: Ian Simpson Sent: Monday, September 07, 2009 5:14 PM To: mysql@lists.mysql.com Subject: Prevent execution of queries without a WHERE clause Hi all, I va

Prevent execution of queries without a WHERE clause

2009-09-07 Thread Ian Simpson
Hi all, I vaguely recall finding mention a MySQL command or start-up option that blocked any update or delete query that didn't have a WHERE component, to prevent statements accidentally affecting too many rows (like those of a certain absent-minded web developer who might work for the same compan

Re: Using Date Functions in Where Clause

2008-04-19 Thread Baron Schwartz
Hi, On Mon, Apr 14, 2008 at 1:54 PM, Jamie Madill <[EMAIL PROTECTED]> wrote: > Hello, > > Basically I want to know if this is a good query for indexing. > > I have the following query: > > select > count(1) as count > from > session > where > last >= DATE_SUB(NOW(), INTERVAL :from SECON

Using Date Functions in Where Clause

2008-04-14 Thread Jamie Madill
Hello, Basically I want to know if this is a good query for indexing. I have the following query: select count(1) as count from session where last >= DATE_SUB(NOW(), INTERVAL :from SECOND) Is it safe to assume that the expression calling the function DATE_SUB is evaluated just once to a f

RE : Re: RE : Re: Left outer joins, where clause and table_names

2007-10-24 Thread tom wang
from titles: > > SELECT * FROM projects > > I'm not sure i understand your schema enough to > help. Are you sure you > need a separate titles table, for instance? Well the name is rather misleading... the database schema was created by my japanese coworker and is not a

Re: RE : Re: Left outer joins, where clause and table_names

2007-10-24 Thread mysql
from titles: SELECT * FROM projects I'm not sure i understand your schema enough to help. Are you sure you need a separate titles table, for instance? And you shouldn't be able to use the alias readerships_topics in the WHERE clause. Come to think of it, your WHERE clause makes n

RE : Re: Left outer joins, where clause and table_names

2007-10-24 Thread tom wang
_topics.read != '1')) I guess I should have given more background > > I can't just the left outer join part as it's > > autogenerated but I can change the WHERE clause > > Autogenerated by what, exactly? Does it run at all > the way it is? That >

OT: "K.I.S.S."? Re: Left outer joins, where clause and table_names

2007-10-24 Thread Ralf Hüsing
tom wang schrieb: Hi, I have the following sql request: SELECT projects.`id` AS t0_r0, projects.`name` AS [..endless sql..] Hi Tom, did you understand that query (in lets say 3 months) if you need to fix a bug? If not it maybe better to simplify that. regards -ralf -- MySQL General Mai

Re: Left outer joins, where clause and table_names

2007-10-24 Thread mysql
readerships_topics.topic_id = topics_posts.id I'll take your word for it! and I have a condition on both of those tables in my where clause: WHERE (readerships.read != '1' OR readerships_topics.read != '1') Not that I'm going to pretend to understand the goal o

Left outer joins, where clause and table_names

2007-10-24 Thread tom wang
;1') AND (roles_users.user_id = '6' OR users_roles_join.user_id = '6')) As you can see I have two left outerjoins involving the readerships table: LEFT OUTER JOIN readerships ON readerships.topic_id = topics.id and LEFT OUTER JOIN readerships readerships_topics ON readersh

Trouble with WHERE Clause

2007-03-12 Thread Richard Kurth
I have two tables I just what the data from the 1 table that is not in the 2 table So in this example I what row formelements_id 22 and 23. I have tried different sql statements one is below SELECT customformelements.formelements_id ,dbelements.customer_id,customformelements.formelements_field_

RE: SELECT single row from 2 tables with WHERE clause

2007-02-25 Thread Kerry Frater
with WHERE clause Hi Kerry, Try this: SELECT t1.*,t2.thedescription AS t2desc FROM table1 AS t1 LEFT JOIN table2 AS t2 ON t1.linkfield=t2.linkfield WHERE t1.lookup='Z' Without the WHERE condition this would return all 1000 rows of table 1 since "A Left join returns

Re: SELECT single row from 2 tables with WHERE clause

2007-02-19 Thread Brian Mansell
It sounds to me like you're needing to use a left outer join on t2. Give that a shot instead of the inner join you're currently using. Cheers, -bemansell On 2/17/07, Kerry Frater <[EMAIL PROTECTED]> wrote: I am trying to select a particular row from a table and include a column for aq second ta

SELECT single row from 2 tables with WHERE clause

2007-02-17 Thread Kerry Frater
I am trying to select a particular row from a table and include a column for aq second table but I cannot get the result I am after. I have "table1" with 1000 rows and "table2" with 12 rows. The relationship between the tables is a column "linkedfield". Table1 has a unique key called "lookup" If

Re: Problems with WHERE clause

2006-07-30 Thread Michael Stassen
gt; p.rider_id=236 and fee > 0 group by s.id order by s.f_date; > > which gives me the error: > > ERROR 1052 (23000): Column 'fee' in where clause is ambiguous > > Without the 'and fee > 0' the query works fine. > > mysql> select version(); &

Re: Problems with WHERE clause

2006-07-30 Thread Martin Jespersen
ice is a waste of cputime. I say trying here because this is what fails, you are not allowed to call sum in your where clause, thus the "Invalid use of group function". try SELECT s.id, s.name, SUM(p.fee) AS fee_total FROM serie AS s INNER JOIN race_serie AS rs ON rs.serie

Re: Problems with WHERE clause

2006-07-30 Thread Jørn Dahl-Stamnes
On Sunday 30 July 2006 12:37, Gabriel PREDA wrote: > You must specify explicitly what 'fee' to use... so if you wand every > p.fee to be greater than zero then you must do: > > SELECT s.id, s.name, SUM(p.fee) AS fee > FROM serie AS s > INNER JOIN race_serie AS rs ON rs.serie_id = s.id >

Re: Problems with WHERE clause

2006-07-30 Thread Gabriel PREDA
You must specify explicitly what 'fee' to use... so if you wand every p.fee to be greater than zero then you must do: SELECT s.id, s.name, SUM(p.fee) AS fee FROM serie AS s INNER JOIN race_serie AS rs ON rs.serie_id = s.id INNER JOIN races AS r ON r.id = rs.race_id INNER JOIN particip

Re: Problems with WHERE clause

2006-07-30 Thread Visolve DB Team
Hello Jørn Dahl-Stamnes, The column 'fee' is existing in more than one table . To overcome this problem use the correct instance name of the table for the column "fee" In WHERE clause select s.id, s.name, sum(p.fee) as fee from serie as s inner join race_

Re: Problems with WHERE clause

2006-07-30 Thread Chris Sansom
; 0 group by s.id order by s.f_date; which gives me the error: ERROR 1052 (23000): Column 'fee' in where clause is ambiguous It looks as if you already have a column called fee in the participants table - I'm looking at "sum(p.fee)" - so you're in trouble if you use

Problems with WHERE clause

2006-07-30 Thread Jørn Dahl-Stamnes
by s.f_date; which gives me the error: ERROR 1052 (23000): Column 'fee' in where clause is ambiguous Without the 'and fee > 0' the query works fine. mysql> select version(); ++ | version() | ++ | 4.1.8-standard | +

Re: Problem with 'or' in 'where' clause? (longish)

2006-04-11 Thread Chris Sansom
At 17:20 +0200 11/4/06, Barry wrote: Japanese say here: Ganbatte! (Do your best!) Oh, so true! DYB! DYB! DYB! Hmmm - now you've confused me a bit. Quoting from the section in the DuBois book: "...a LEFT JOIN forces the result set to contain a row for every row in the left side table, wheth

Re: Problem with 'or' in 'where' clause? (longish)

2006-04-11 Thread Barry
Barry wrote: Chris Sansom wrote: Yeah - it certainly seems promising. Better do some more reading! Japanese say here: Ganbatte! (Do your best!) Hmmm - now you've confused me a bit. Quoting from the section in the DuBois book: "...a LEFT JOIN forces the result set to contain a row for eve

Re: Problem with 'or' in 'where' clause? (longish)

2006-04-11 Thread Barry
Chris Sansom wrote: Yeah - it certainly seems promising. Better do some more reading! Japanese say here: Ganbatte! (Do your best!) Hmmm - now you've confused me a bit. Quoting from the section in the DuBois book: "...a LEFT JOIN forces the result set to contain a row for every row in the

Re: Problem with 'or' in 'where' clause? (longish)

2006-04-11 Thread Chris Sansom
content) WHERE t2.id = t1.id (Hi, i'm table 2 but only giving you the content you wanted to see with your WHERE clause, i keep the rest for myself!!) Hmmm - now you've confused me a bit. Quoting from the section in the DuBois book: "...a LEFT JOIN forces the result set to conta

Re: Problem with 'or' in 'where' clause? (longish)

2006-04-11 Thread Barry
= table2.id LEFT join puts the WHOLE table2 to the right of the LEFT JOINED table1. example: (Hi, i'm table 1 with all my content) LEFT JOIN (Hi, i'm table 2 with all my content) if you use Where: (Hi, i'm table 1 with all my content) WHERE t2.id = t1.id (Hi, i'm table 2 but

Re: Problem with 'or' in 'where' clause? (longish)

2006-04-11 Thread Chris Sansom
At 16:37 +0200 11/4/06, Barry wrote: select [what you want] from t1 LEFT JOIN t2 ON t2.id = t1.id LEFT JOIN t3 ON t3.id = t1.id LEFT JOIN t4 ON t4.id = t1.id LEFT JOIN t5 ON t5.id = t1.id LEFT JOIN t6 ON t6.id = t1.id where t2.text like '%search_term%' OR t3.text like '%search_term%' O

Re: Problem with 'or' in 'where' clause? (longish)

2006-04-11 Thread Chris Sansom
At 9:28 -0500 11/4/06, mos wrote: If you keep it in 5 different tables, the search will be as slow as molasses in January because of the joins. I'd recommend using FullText search on the text field. Hi Mike Thanks for the rapid response! OK - I've set all those text fields as FullTex

Re: Problem with 'or' in 'where' clause? (longish)

2006-04-11 Thread Barry
Chris Sansom wrote: Ah forgot something. Make sure you have placed indizies on the 'id' fields. This will make it even faster. Greets Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- MySQL General Mailing List For list archives: http://lists.mysq

Re: Problem with 'or' in 'where' clause? (longish)

2006-04-11 Thread Barry
Chris Sansom wrote: First I should say I'm using MySQL 3.23.x because that's what's currently available on our host's server. An upgrade to 5.x is promised any time now, but I'm not holding my breath! So, with that in mind... I'm trying to do quite a sophisticated search across several tables

Re: Problem with 'or' in 'where' clause? (longish)

2006-04-11 Thread mos
Chris, If you keep it in 5 different tables, the search will be as slow as molasses in January because of the joins. I'd recommend using FullText search on the text field. You *may* be able to do a Merge table on the 5 tables so MySQL sees it as 1 table. I'm not sure which of these feat

Problem with 'or' in 'where' clause? (longish)

2006-04-11 Thread Chris Sansom
First I should say I'm using MySQL 3.23.x because that's what's currently available on our host's server. An upgrade to 5.x is promised any time now, but I'm not holding my breath! So, with that in mind... I'm trying to do quite a sophisticated search across several tables and am running into

Re: need help with user variables in where clause of sub query

2005-12-29 Thread SGreen
Dan Rossi <[EMAIL PROTECTED]> wrote on 12/29/2005 07:19:13 AM: > Thanks for your kind words of opinion, if you feel you have a better > way please do go ahead , i am going to show you the sql i ended up > using which was a union to append the current summary at the end, i > then had to use php

Re: need help with user variables in where clause of sub query

2005-12-29 Thread Dan Rossi
D=c.customerID INNER JOIN feeds f ON fu.feedID=f.feedID WHERE f.feedID IN (SELECT feedID FROM producers_join WHERE producerID IN (3)) GROUP BY fu.month,fu.customerID ORDER BY fu.month DESC END On 28/12/2005, at 4:47 PM, [EMAIL PROTECTED] wrote: Dan Rossi <[EMAIL PROTECTED]> wrote on 12/2

Re: need help with user variables in where clause of sub query

2005-12-28 Thread SGreen
ND [EMAIL PROTECTED] AND fu.feedID IN (SELECT > >> > feedID FROM producers_join WHERE producerID IN (3))), > >> > > >> > @percentage:=((@feed_bandwidth/@total_bandwidth)) AS percentage, > >> > > >> > @month_totals:=(SELECT month_total FROM month_totals WHERE > >> > [EMAIL PROTECTED] AND DATE_FORMAT(month,"%m")[EMAIL PROTECTED] GROUP BY > >> > month, customerID) AS month_totals, > >> > > >> > @count:=(SELECT count(*) FROM feeds WHERE feedID IN (@feeds)), > >> > > >> > @feed_count:=(SELECT count(*) FROM month_totals WHERE > >> > [EMAIL PROTECTED] AND [EMAIL PROTECTED] AND feedID IN (SELECT > >> feedID > >> > FROM producers_join WHERE producerID IN (3))), > >> > > >> > ROUND(( IF(c.bandwidth_limit=0, > >> > ((c.monthly_price/@count)*f.percentage_paid)[EMAIL PROTECTED], > >> > ((@[EMAIL PROTECTED])*f.percentage_paid) )),0) AS > >> providers_cut > >> > > >> > FROM feed_usage fu INNER JOIN customers c ON > >> fu.customerID=c.customerID > >> > INNER JOIN feeds f ON fu.feedID=f.feedID WHERE f.feedID IN (SELECT > >> > feedID FROM producers_join WHERE producerID IN (3)) GROUP BY > >> > fu.month,fu.customerID ORDER BY fu.month DESC > >> > > >> > END > >> > > >> > On 28/12/2005, at 4:47 PM, [EMAIL PROTECTED] wrote: > >> > > >> > > Dan Rossi <[EMAIL PROTECTED]> wrote on 12/27/2005 11:39:57 > >> PM: > >> > > > >> > >> Hi there i am trying to use usewr variables in a select > >> statement to > >> > >> add to a where clause in a sub query. Ie

Re: need help with user variables in where clause of sub query

2005-12-28 Thread Dan Rossi
thly_price/@count)*f.percentage_paid)[EMAIL PROTECTED], > ((@[EMAIL PROTECTED])*f.percentage_paid) )),0) AS providers_cut > > FROM feed_usage fu INNER JOIN customers c ON fu.customerID=c.customerID > INNER JOIN feeds f ON fu.feedID=f.feedID WHERE f.feedID IN (SELECT > feedID

Re: need help with user variables in where clause of sub query

2005-12-28 Thread Dan Rossi
> feedID FROM producers_join WHERE producerID IN (3)) GROUP BY > fu.month,fu.customerID ORDER BY fu.month DESC > > END > > On 28/12/2005, at 4:47 PM, [EMAIL PROTECTED] wrote: > > > Dan Rossi <[EMAIL PROTECTED]> wrote on 12/27/2005 11:39:57 PM: > > &g

Re: need help with user variables in where clause of sub query

2005-12-28 Thread Dan Rossi
CT feedID FROM producers_join WHERE producerID IN (3)) GROUP BY fu.month,fu.customerID ORDER BY fu.month DESC END On 28/12/2005, at 4:47 PM, [EMAIL PROTECTED] wrote: Dan Rossi <[EMAIL PROTECTED]> wrote on 12/27/2005 11:39:57 PM: Hi there i am trying to use usewr variables in a select stat

Re: need help with user variables in where clause of sub query

2005-12-28 Thread SGreen
AS providers_cut > > FROM feed_usage fu INNER JOIN customers c ON fu.customerID=c.customerID > INNER JOIN feeds f ON fu.feedID=f.feedID WHERE f.feedID IN (SELECT > feedID FROM producers_join WHERE producerID IN (3)) GROUP BY > fu.month,fu.customerID ORDER BY fu.month DESC > > END

Re: need help with user variables in where clause of sub query

2005-12-27 Thread Dan Rossi
4:47 PM, [EMAIL PROTECTED] wrote: Dan Rossi <[EMAIL PROTECTED]> wrote on 12/27/2005 11:39:57 PM: Hi there i am trying to use usewr variables in a select statement to add to a where clause in a sub query. Ie select @id:=id,@month:=month, (select SUM(totals) from table where [EMAIL PROTECTE

Re: need help with user variables in where clause of sub query

2005-12-27 Thread SGreen
Dan Rossi <[EMAIL PROTECTED]> wrote on 12/27/2005 11:39:57 PM: > Hi there i am trying to use usewr variables in a select statement to > add to a where clause in a sub query. Ie > > select @id:=id,@month:=month, (select SUM(totals) from table where > [EMAIL PROTECTED] and

need help with user variables in where clause of sub query

2005-12-27 Thread Dan Rossi
Hi there i am trying to use usewr variables in a select statement to add to a where clause in a sub query. Ie select @id:=id,@month:=month, (select SUM(totals) from table where [EMAIL PROTECTED] and [EMAIL PROTECTED]) as totals from table its happened on other occasions ie with calculations

Re: Joins - where clause, booking system

2005-11-17 Thread sheeri kritzer
Your query was: SELECT distinct accomodation.accom_id FROM accomodation LEFT JOIN student_accom ON accomodation.accom_id = student_accom.accom_id where ((student_accom.start_date Between '2005-10-01' And '2005-11-30') OR (student_accom.leave_date Between '2005-10-01' And '2005-10-30')) The logic:

Re: Joins - where clause, booking system

2005-11-17 Thread Brent Baisley
Not sure what you are asking for. If you are trying to get the opposite of what you are getting, try adding AND student_accom.start_date IS NULL to the end of the query. You can actually use just about any field instead of start_date. For easier readability, you can rephrase your query to

Joins - where clause, booking system

2005-11-16 Thread gavin
Hello, I'm running mysql 4.0.12 I have a bookings database in which I'm having problems pulling out the available accomodation. Tables are: Accomodation - accomid (primary key), town, address, contactnumber etc student_accom - studentaccomid (primary key), accomid, studentid My query is as follo

Re: COUNT (*): Fast if NO where clause. slow with WHERE clause (yes, slow even if index is used).

2005-07-12 Thread Jocelyn Fournier
Hi, What about SELECT count(*) FROM table1 - SELECT count(*) FROM table1 WHERE status = 1 ? (this query should be mush faster) Regards, Jocelyn jpow wrote: Hi everyone, I have this problem of slow "count *" when I use a where clause. 1. I have a table of ~1m rows. 2. There is

COUNT (*): Fast if NO where clause. slow with WHERE clause (yes, slow even if index is used).

2005-07-12 Thread jpow
Hi everyone, I have this problem of slow "count *" when I use a where clause. 1. I have a table of ~1m rows. 2. There is a "status" column which can be 0 or 1. 3. Most of the rows have a status of 0, but maybe 10% of them have a status of 1. 4. I need to know how many records

Re: EXPLAIN does not explain the WHERE clause

2005-03-01 Thread gerald_clark
Christopher Malton wrote: When I use the statement: EXPLAIN SELECT * FROM workunits WHERE Sent>0 It returns +---+--+---++-++-++ | table | type | possible_keys | key| key_len | ref| rows| Extra | +---

EXPLAIN does not explain the WHERE clause

2005-03-01 Thread Christopher Malton
When I use the statement:   EXPLAIN SELECT * FROM workunits WHERE Sent>0   It returns   +---+--+---++-++-++ | table | type | possible_keys | key    | key_len | ref    | rows    | Extra  | +---+--

Re: alias not allowed in WHERE clause?

2004-10-12 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Morten Egan <[EMAIL PROTECTED]> writes: > Well, it might not be SQL standard, but most databases out there allow > you to use the alias in your where clauses. It helps make the sql more > readable, and it shouldn't be that hard to add this feature to the > parser, s

[Fwd: Re: Where clause question]

2004-10-11 Thread Morten Egan
Sorry, mailed it in html format. Read answer below Original Message Subject:Re: Where clause question Date: Tue, 12 Oct 2004 00:00:12 +0200 From: Morten Egan <[EMAIL PROTECTED]> To: Ed Lazor <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] Not kno

Re: alias not allowed in WHERE clause?

2004-10-11 Thread John McCaskey
> >> ), 2 ) + POWER( ( > >> longitude + 95.689508 > >> ), 2 ) ) AS distance > >> FROM geographics > >> WHERE distance <1 > >> ORDER BY distance > >> LIMIT 10; > >> > >> Returns: > >> #1054 - Unknow

Re: Where clause question

2004-10-11 Thread Eamon Daly
- Original Message - From: "Ed Lazor" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, October 11, 2004 4:51 PM Subject: RE: Where clause question Interesting. I thought you could sort by aliases. Thanks Shawn. The easy answer was to just add the calculati

RE: Where clause question

2004-10-11 Thread Ed Lazor
Interesting. I thought you could sort by aliases. Thanks Shawn. The easy answer was to just add the calculation to the where section as well. But which approach is faster - "having" or the calculation? Ie. select ID, Title, MSRP, Price, round( ( (MSRP - Price) / MSRP) * 100) as discount from

Re: alias not allowed in WHERE clause?

2004-10-11 Thread Morten Egan
n column 'distance' in 'where clause' Are alias not allowed in WHERE clauses? How could they be? The WHERE clause determines which rows to select. Aliases are defined for columns from the rows that have been selected. I am able to replace the alias with the entire math funct

  1   2   3   >