RE: Anything wrong with this code?

2008-06-06 Thread Richard Meredith-Hardy
As this is a bulk insert sort of query you should be able to insert what are
effectively constants relative to all the rows you're inserting, for
example:

insert
 into hmls_commercial
( mls_number,INSERTED_BY,INSERTED_ON )
 select mls_number,'Rick',#createodbcdatetime(now())#
 from hmls_commercial_temp
 where mls_number
 not in ( select substring_index(mls_number, '_', 1 )
  as mls_num
from hmls_commercial )

Will put 'Rick' and the current date-time in every inserted row.

If you need to be more dynamic than this you'll have to select ID's with a
'not in' query like the above and then loop over them inserting each new row
individually.

hth

Richard

 -Original Message-
 From: Rick Faircloth [mailto:[EMAIL PROTECTED] 
 Sent: 05 June 2008 19:42
 To: CF-Talk
 Subject: RE: Anything wrong with this code?
 
 Ok, that's working (using a different table for the insert, 
 'hmls_commercial' rather than the 'properties' table for 
 testing) with this code
 
 insert
   into hmls_commercial
( mls_number )
 select mls_number
   from hmls_commercial_temp
  where mls_number
 not in ( select substring_index(mls_number, '_', 1 )
  as mls_num
from hmls_commercial )
 
 I had to use 'substring_index...' because the mls_number in 
 the final table is tagged with _h or _s depending on which 
 MLS the property data is from.
 
 The final issue with this query, however, is how do I insert 
 values that are not in the table supplying the data.
 
 What I mean is, when I run the query, I need to insert extra 
 data into the target table, such as:
 
 values ( cfqueryparam cfsqltype='cf_sql_varchar' value='hmls',
  cfqueryparam cfsqltype='cf_sql_varchar' 
 value='#mls_number#_h' )
 
 How would I write the query so I can specify other values to 
 be inserted?
 
 I had this same problem using the 'dual' function in mysql... 
 it checked for the duplicates, but I couldn't insert 
 additional values because the column count didn't match.  At 
 least I couldn't figure out a way to do it.
 
 But is it possible to modify your query for the additional 
 values, Jochem?
 
 Thanks,
 
 Rick
 
 
 
  -Original Message-
  From: Jochem van Dieten [mailto:[EMAIL PROTECTED]
  Sent: Thursday, June 05, 2008 1:58 PM
  To: CF-Talk
  Subject: Re: Anything wrong with this code?
  
  Rick Faircloth wrote:
   (Simplified version... MySQL 5)
  
   cfloop query='get_hmls_commercial_data'
  
   cfquery name='insert_data' datasource='x'
  
  Do get_hmls_commercial_data and insert_data query the same 
 database? 
  In that case you should do:
  
  INSERT INTO properties (mls_number)
  SELECT ...
  FROM   ...
  WHERE  mls_number NOT IN (
  SELECT mls_number
  FROM properties
  )
  
  Jochem
  
  
 
 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306948
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Anything wrong with this code?

2008-06-05 Thread Rick Faircloth
Kind of a dumb thing I'm trying to do...trying to combine
an insert statement with a where clause.

I think I need another approach.

Back to the drawing board...

Rick


 -Original Message-
 From: Rick Faircloth [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 05, 2008 11:40 AM
 To: CF-Talk
 Subject: Anything wrong with this code?
 
 (Simplified version... MySQL 5)
 
 cfloop query='get_hmls_commercial_data'
 
 cfquery name='insert_data' datasource='x'
 
  insert into properties
 
 (mls_number)
 
  values (cfqueryparam cfsqltype='cf_sql_varchar'
 value='#get_hmls_commercial_data.mls_number#_h' null='#not 
 len(trim(mls_number))#')
 
   where '#get_hmls_commercial_data.mls_number#_h' not in
 (select mls_number from properties)
 
 /cfquery
 
 /cfloop
 
 I'm getting this error upon execution of the template...
 
 Error Executing Database Query.
 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
 'where '39438_h' not exists in (select mls_number from prope' at line 32
 
 ???
 
 Thanks,
 
 Rick
 
 
 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306894
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Anything wrong with this code?

2008-06-05 Thread Andrew Scott
:-) it sounds like version of mysql doesn't support


 where '#get_hmls_commercial_data.mls_number#_h' not in
   (select mls_number from properties)

On Fri, Jun 6, 2008 at 1:56 AM, Rick Faircloth [EMAIL PROTECTED]
wrote:

 Kind of a dumb thing I'm trying to do...trying to combine
 an insert statement with a where clause.

 I think I need another approach.

 Back to the drawing board...

 Rick


  -Original Message-
  From: Rick Faircloth [mailto:[EMAIL PROTECTED]
  Sent: Thursday, June 05, 2008 11:40 AM
  To: CF-Talk
  Subject: Anything wrong with this code?
 
  (Simplified version... MySQL 5)
 
  cfloop query='get_hmls_commercial_data'
 
  cfquery name='insert_data' datasource='x'
 
   insert into properties
 
  (mls_number)
 
   values (cfqueryparam cfsqltype='cf_sql_varchar'
  value='#get_hmls_commercial_data.mls_number#_h' null='#not
 len(trim(mls_number))#')
 
where '#get_hmls_commercial_data.mls_number#_h' not in
  (select mls_number from properties)
 
  /cfquery
 
  /cfloop
 
  I'm getting this error upon execution of the template...
 
  Error Executing Database Query.
  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
  'where '39438_h' not exists in (select mls_number from prope' at line 32
 
  ???
 
  Thanks,
 
  Rick
 
 
 

 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306896
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Anything wrong with this code?

2008-06-05 Thread Burns, John D
Just a quick glance but could you do something like:

Insert into properties(mls_number)
Values(select mls_number from table where whatever)

I think that's the syntac but you may not need the values piece. I can't
remember off hand but I've done combined insert/select statements like
that before and it basically inserts a row for each row it selects. Does
that make sense? The other thing you could do is a Query of a query
before you do the loop and weed it out so you only have the criteria you
want coming into the loop. Hope that helps.

John

-Original Message-
From: Rick Faircloth [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 05, 2008 11:57 AM
To: CF-Talk
Subject: RE: Anything wrong with this code?

Kind of a dumb thing I'm trying to do...trying to combine
an insert statement with a where clause.

I think I need another approach.

Back to the drawing board...

Rick


 -Original Message-
 From: Rick Faircloth [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 05, 2008 11:40 AM
 To: CF-Talk
 Subject: Anything wrong with this code?
 
 (Simplified version... MySQL 5)
 
 cfloop query='get_hmls_commercial_data'
 
 cfquery name='insert_data' datasource='x'
 
  insert into properties
 
 (mls_number)
 
  values (cfqueryparam cfsqltype='cf_sql_varchar'
 value='#get_hmls_commercial_data.mls_number#_h' null='#not
len(trim(mls_number))#')
 
   where '#get_hmls_commercial_data.mls_number#_h' not in
 (select mls_number from properties)
 
 /cfquery
 
 /cfloop
 
 I'm getting this error upon execution of the template...
 
 Error Executing Database Query.
 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
 'where '39438_h' not exists in (select mls_number from prope' at line
32
 
 ???
 
 Thanks,
 
 Rick
 
 
 



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306897
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Anything wrong with this code?

2008-06-05 Thread Phillip Vector
What are you trying to do. I may be able to suggest an idea.

On Thu, Jun 5, 2008 at 8:56 AM, Rick Faircloth [EMAIL PROTECTED] wrote:
 Kind of a dumb thing I'm trying to do...trying to combine
 an insert statement with a where clause.

 I think I need another approach.

 Back to the drawing board...

 Rick


 -Original Message-
 From: Rick Faircloth [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 05, 2008 11:40 AM
 To: CF-Talk
 Subject: Anything wrong with this code?

 (Simplified version... MySQL 5)

 cfloop query='get_hmls_commercial_data'

 cfquery name='insert_data' datasource='x'

  insert into properties

 (mls_number)

  values (cfqueryparam cfsqltype='cf_sql_varchar'
 value='#get_hmls_commercial_data.mls_number#_h' null='#not 
 len(trim(mls_number))#')

   where '#get_hmls_commercial_data.mls_number#_h' not in
 (select mls_number from properties)

 /cfquery

 /cfloop

 I'm getting this error upon execution of the template...

 Error Executing Database Query.
 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
 'where '39438_h' not exists in (select mls_number from prope' at line 32

 ???

 Thanks,

 Rick




 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306898
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Anything wrong with this code?

2008-06-05 Thread Dominic Watson
Not sure about MySQL but this would work in MSSql

IF (NOT EXISTS ( select * from properties where mls_number =
cfqueryparam cfsqltype='cf_sql_varchar'
value='#get_hmls_commercial_data.mls_number#_h'  )
BEGIN
 insert into properties (mls_number)
 values (cfqueryparam cfsqltype='cf_sql_varchar'
value='#get_hmls_commercial_data.mls_number#_h' null='#not
len(trim(mls_number))#')
END


Also, I suspect you don't really want the NULL in that cfqueryparam,
but I may be wrong (?)

HTH

Dominic

2008/6/5 Rick Faircloth [EMAIL PROTECTED]:
 Kind of a dumb thing I'm trying to do...trying to combine
 an insert statement with a where clause.

 I think I need another approach.

 Back to the drawing board...

 Rick


 -Original Message-
 From: Rick Faircloth [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 05, 2008 11:40 AM
 To: CF-Talk
 Subject: Anything wrong with this code?

 (Simplified version... MySQL 5)

 cfloop query='get_hmls_commercial_data'

 cfquery name='insert_data' datasource='x'

  insert into properties

 (mls_number)

  values (cfqueryparam cfsqltype='cf_sql_varchar'
 value='#get_hmls_commercial_data.mls_number#_h' null='#not 
 len(trim(mls_number))#')

   where '#get_hmls_commercial_data.mls_number#_h' not in
 (select mls_number from properties)

 /cfquery

 /cfloop

 I'm getting this error upon execution of the template...

 Error Executing Database Query.
 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
 'where '39438_h' not exists in (select mls_number from prope' at line 32

 ???

 Thanks,

 Rick




 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306900
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Anything wrong with this code?

2008-06-05 Thread Eric Roberts
That would be a cool feature if they added that to SQL so you could do that.
You could test to see if the mls number already exists, if not, then insert
it...I am not a DBA, but I am sure there is also a SQL solution to doing
this as well.  I would just check using CF personally.

Eric

/*-Original Message-
/*From: Rick Faircloth [mailto:[EMAIL PROTECTED]
/*Sent: Thursday, June 05, 2008 10:57 AM
/*To: CF-Talk
/*Subject: RE: Anything wrong with this code?
/*
/*Kind of a dumb thing I'm trying to do...trying to combine
/*an insert statement with a where clause.
/*
/*I think I need another approach.
/*
/*Back to the drawing board...
/*
/*Rick
/*
/*
/* -Original Message-
/* From: Rick Faircloth [mailto:[EMAIL PROTECTED]
/* Sent: Thursday, June 05, 2008 11:40 AM
/* To: CF-Talk
/* Subject: Anything wrong with this code?
/*
/* (Simplified version... MySQL 5)
/*
/* cfloop query='get_hmls_commercial_data'
/*
/* cfquery name='insert_data' datasource='x'
/*
/*  insert into properties
/*
/* (mls_number)
/*
/*  values (cfqueryparam cfsqltype='cf_sql_varchar'
/* value='#get_hmls_commercial_data.mls_number#_h' null='#not
/*len(trim(mls_number))#')
/*
/*   where '#get_hmls_commercial_data.mls_number#_h' not in
/* (select mls_number from properties)
/*
/* /cfquery
/*
/* /cfloop
/*
/* I'm getting this error upon execution of the template...
/*
/* Error Executing Database Query.
/* 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
/* 'where '39438_h' not exists in (select mls_number from prope' at line 32
/*
/* ???
/*
/* Thanks,
/*
/* Rick
/*
/*
/*
/*
/*

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306910
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Anything wrong with this code?

2008-06-05 Thread Rick Faircloth
I gave that syntax a try, but MySQL didn't like even the if
at the beginning.

Thanks anyway...

Rick

 -Original Message-
 From: Dominic Watson [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 05, 2008 12:05 PM
 To: CF-Talk
 Subject: Re: Anything wrong with this code?
 
 Not sure about MySQL but this would work in MSSql
 
 IF (NOT EXISTS ( select * from properties where mls_number =
 cfqueryparam cfsqltype='cf_sql_varchar'
 value='#get_hmls_commercial_data.mls_number#_h'  )
 BEGIN
  insert into properties (mls_number)
  values (cfqueryparam cfsqltype='cf_sql_varchar'
 value='#get_hmls_commercial_data.mls_number#_h' null='#not
 len(trim(mls_number))#')
 END
 
 
 Also, I suspect you don't really want the NULL in that cfqueryparam,
 but I may be wrong (?)
 
 HTH
 
 Dominic
 
 2008/6/5 Rick Faircloth [EMAIL PROTECTED]:
  Kind of a dumb thing I'm trying to do...trying to combine
  an insert statement with a where clause.
 
  I think I need another approach.
 
  Back to the drawing board...
 
  Rick
 
 
  -Original Message-
  From: Rick Faircloth [mailto:[EMAIL PROTECTED]
  Sent: Thursday, June 05, 2008 11:40 AM
  To: CF-Talk
  Subject: Anything wrong with this code?
 
  (Simplified version... MySQL 5)
 
  cfloop query='get_hmls_commercial_data'
 
  cfquery name='insert_data' datasource='x'
 
   insert into properties
 
  (mls_number)
 
   values (cfqueryparam cfsqltype='cf_sql_varchar'
  value='#get_hmls_commercial_data.mls_number#_h' null='#not 
  len(trim(mls_number))#')
 
where '#get_hmls_commercial_data.mls_number#_h' not in
  (select mls_number from properties)
 
  /cfquery
 
  /cfloop
 
  I'm getting this error upon execution of the template...
 
  Error Executing Database Query.
  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
  'where '39438_h' not exists in (select mls_number from prope' at line 32
 
  ???
 
  Thanks,
 
  Rick
 
 
 
 
 
 
 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306912
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Anything wrong with this code?

2008-06-05 Thread Joe Velez
Isn't it supposed to be

WHERE [COLUMN] not in (select mls_number from properties)...

Joe Velez

Rick Faircloth wrote:
 (Simplified version... MySQL 5)

 cfloop query='get_hmls_commercial_data'

 cfquery name='insert_data' datasource='x'

  insert into properties

 (mls_number)

  values (cfqueryparam cfsqltype='cf_sql_varchar'
 value='#get_hmls_commercial_data.mls_number#_h' null='#not 
 len(trim(mls_number))#')

   where '#get_hmls_commercial_data.mls_number#_h' not in
 (select mls_number from properties)

 /cfquery

 /cfloop

 I'm getting this error upon execution of the template...

 Error Executing Database Query.  
 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
 'where '39438_h' not exists in (select mls_number from prope' at line 32

 ???

 Thanks,

 Rick


 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306914
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Anything wrong with this code?

2008-06-05 Thread Rick Faircloth
Here's what I'm trying to accomplish...it's relatively simple,
or so I thought.

Got a temp table of data (hmls_commercial_temp).
I want to transfer that data to the table, hmls_commercial.

Before I transfer the records, I want to check and make sure
a record for each row in hmls_commercial_temp doesn't already
exist in the hmls_commercial table.

This is a better approach than doing complete wipe of the data
in the receiving table and just replacing all the records.  That
seems like a waste of time and resources.

Suggestions?

Thanks,

Rick

 -Original Message-
 From: Phillip Vector [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 05, 2008 12:03 PM
 To: CF-Talk
 Subject: Re: Anything wrong with this code?
 
 What are you trying to do. I may be able to suggest an idea.
 
 On Thu, Jun 5, 2008 at 8:56 AM, Rick Faircloth [EMAIL PROTECTED] wrote:
  Kind of a dumb thing I'm trying to do...trying to combine
  an insert statement with a where clause.
 
  I think I need another approach.
 
  Back to the drawing board...
 
  Rick
 
 
  -Original Message-
  From: Rick Faircloth [mailto:[EMAIL PROTECTED]
  Sent: Thursday, June 05, 2008 11:40 AM
  To: CF-Talk
  Subject: Anything wrong with this code?
 
  (Simplified version... MySQL 5)
 
  cfloop query='get_hmls_commercial_data'
 
  cfquery name='insert_data' datasource='x'
 
   insert into properties
 
  (mls_number)
 
   values (cfqueryparam cfsqltype='cf_sql_varchar'
  value='#get_hmls_commercial_data.mls_number#_h' null='#not 
  len(trim(mls_number))#')
 
where '#get_hmls_commercial_data.mls_number#_h' not in
  (select mls_number from properties)
 
  /cfquery
 
  /cfloop
 
  I'm getting this error upon execution of the template...
 
  Error Executing Database Query.
  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
  'where '39438_h' not exists in (select mls_number from prope' at line 32
 
  ???
 
  Thanks,
 
  Rick
 
 
 
 
 
 
 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306923
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Anything wrong with this code?

2008-06-05 Thread Jochem van Dieten
Rick Faircloth wrote:
 (Simplified version... MySQL 5)
 
 cfloop query='get_hmls_commercial_data'
 
 cfquery name='insert_data' datasource='x'

Do get_hmls_commercial_data and insert_data query the same database? In 
that case you should do:

INSERT INTO properties (mls_number)
SELECT ...
FROM   ...
WHERE  mls_number NOT IN (
SELECT mls_number
FROM properties
)

Jochem

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306922
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Anything wrong with this code? - Shameless Plug

2008-06-05 Thread Wil Genovese
[ADVERT]

Or, simply purchase a ready to go MLS search solution from the company  
I work for.  We have the MLS data for over 200 MLS markets.

http://www.wolfnet.com
http://www.mlsfinder.com

[/ADVERT]

Wil Genovese
Sr. Web Application Developer

One man with courage makes a majority.
-Andrew Jackson

A fine is a tax for doing wrong. A tax is a fine for doing well.

On Jun 5, 2008, at 12:58 PM, Jochem van Dieten wrote:

 Rick Faircloth wrote:
 (Simplified version... MySQL 5)

 cfloop query='get_hmls_commercial_data'

 cfquery name='insert_data' datasource='x'

 Do get_hmls_commercial_data and insert_data query the same database?  
 In
 that case you should do:

 INSERT INTO properties (mls_number)
 SELECT ...
 FROM   ...
 WHERE  mls_number NOT IN (
   SELECT mls_number
   FROM properties
   )

 Jochem

 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306924
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Anything wrong with this code?

2008-06-05 Thread Rick Faircloth
Ok, that's working (using a different table for the insert,
'hmls_commercial' rather than the 'properties' table for testing)
with this code

insert
  into hmls_commercial
   ( mls_number )
select mls_number
  from hmls_commercial_temp
 where mls_number
not in ( select substring_index(mls_number, '_', 1 )
 as mls_num
   from hmls_commercial )

I had to use 'substring_index...' because the mls_number
in the final table is tagged with _h or _s depending on which
MLS the property data is from.

The final issue with this query, however, is how do I insert
values that are not in the table supplying the data.

What I mean is, when I run the query, I need to insert extra
data into the target table, such as:

values ( cfqueryparam cfsqltype='cf_sql_varchar' value='hmls',
 cfqueryparam cfsqltype='cf_sql_varchar' value='#mls_number#_h' )

How would I write the query so I can specify other values to be inserted?

I had this same problem using the 'dual' function in mysql... it checked for
the duplicates, but I couldn't insert additional values because the column
count didn't match.  At least I couldn't figure out a way to do it.

But is it possible to modify your query for the additional values, Jochem?

Thanks,

Rick



 -Original Message-
 From: Jochem van Dieten [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 05, 2008 1:58 PM
 To: CF-Talk
 Subject: Re: Anything wrong with this code?
 
 Rick Faircloth wrote:
  (Simplified version... MySQL 5)
 
  cfloop query='get_hmls_commercial_data'
 
  cfquery name='insert_data' datasource='x'
 
 Do get_hmls_commercial_data and insert_data query the same database? In
 that case you should do:
 
 INSERT INTO properties (mls_number)
 SELECT ...
 FROM   ...
 WHERE  mls_number NOT IN (
   SELECT mls_number
   FROM properties
   )
 
 Jochem
 
 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306928
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Anything wrong with this code?

2008-06-05 Thread Rick Faircloth
Ok... it works like this:

insert
  into hmls_commercial
   ( mls_number, listing_office )
select mls_number, 'hmls' as listing_office
  from hmls_commercial_temp
 where mls_number
not in ( select substring_index(mls_number, '_', 1 )
 as mls_num
 from hmls_commercial )



 -Original Message-
 From: Rick Faircloth [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 05, 2008 2:42 PM
 To: CF-Talk
 Subject: RE: Anything wrong with this code?
 



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306934
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4