New topic: 

SQL - delete only the DATA in a column?

<http://forums.realsoftware.com/viewtopic.php?t=47223>

         Page 1 of 1
   [ 4 posts ]                 Previous topic | Next topic          Author  
Message        RicSum          Post subject: SQL - delete only the DATA in a 
column?Posted: Fri Mar 08, 2013 9:40 pm                         
Joined: Fri Jun 05, 2009 4:54 pm
Posts: 448
Location: London, England                Hi,
My RealSQL Table name is "SettingsTable" and the column name is "CCTV"
I am trying to delete ALL THE ROWS / DATA in the column, but NOT delete the 
column itself.

I have the following code:

Delete from SettingsTable where CCTV="1"
How do I modify this line in order to delete ALL rows / data in that column 
(but keep the actual column)?

All the websites I have looked at only explain how to delete certain rows and 
not ALL rows.

Hope someone can help.

Thank you all in advance.      
_________________
RealStudio Professional Edition 2012 r2
Developing on OS X  10.8 (Mountain Lion)
Deploying on Windows XP / 7 / 8  
                             Top                Specialised          Post 
subject: Re: SQL - delete only the DATA in a column?Posted: Fri Mar 08, 2013 
9:48 pm                                 
Joined: Thu Aug 26, 2010 6:57 am
Posts: 545
Location: Sydney Australia                UPDATE table_name SET `column_name` = 
NULL

Delete will remove the row

Code may be slightly different between DB's - above was from MySQL.
The principle is the same.      
_________________
Regards

Chris Musty
Specialised Technologies Pty Ltd
http://www.specialised.net.au
-----------------------------------------------
Latest RB Enterprise (12r2) on Win 8 Pro, Ubuntu 12.04 - ahh the pressure I am 
about to MAC it up also!
Turnkey Linux Appliances on Amazon Web Services = unbelievably easy to deploy 
servers for WE.  
                             Top                RicSum          Post subject: 
Re: SQL - delete only the DATA in a column?Posted: Sat Mar 09, 2013 12:25 am    
                     
Joined: Fri Jun 05, 2009 4:54 pm
Posts: 448
Location: London, England                Thank you very much.

I have a single column ListBox, which is populated from a database.
I am trying to get the database to update itself, should the user drag-reorder 
any rows in the ListBox.

I have the code below (in the DragReorderRows event), which succeeds in 
blanking out the database's column data, but does not repopulate the database's 
column with the new REORDERED ListBox data:

dim sql as string
sql="UPDATE SettingsTable SET CCTV = NULL"
db14.sqlexecute (sql)

if db14.error then
  db14_error
else
  db.commit
end if



Dim i as Integer
For i = 0 to Listbox1.RowCount-1
  sql = "INSERT INTO SettingsTable (CCTV) VALUES(Listbox1.Cell(i,0))
  
  if db14.error then
  db14_error
  else
  db.commit
  end if



I think the error lies in this line:
sql = "INSERT INTO SettingsTable (CCTV) VALUES(Listbox1.Cell(i,0))


All help appreciated.      
_________________
RealStudio Professional Edition 2012 r2
Developing on OS X  10.8 (Mountain Lion)
Deploying on Windows XP / 7 / 8  
                             Top                DaveS          Post subject: 
Re: SQL - delete only the DATA in a column?Posted: Sat Mar 09, 2013 12:42 am    
                             
Joined: Sun Aug 05, 2007 10:46 am
Posts: 4628
Location: San Diego, CA                sql = "INSERT INTO SettingsTable (CCTV) 
VALUES(" +chrb(34)+Listbox1.Cell(i,0)+chrb(34)+")"      
_________________
Dave Sisemore
MacPro, OSX Lion 10.7.4 RB2012r1
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 4 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to