Solved

sql statement

Posted on 2006-07-09
10
238 Views
Last Modified: 2010-04-30
mysql 5.0


correct sql statemnt to change a column from yes to no
0
Comment
Question by:thenone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 250 total points
ID: 17070551
>correct sql statemnt to change a column from yes to no

put in here the correct name of the table and the columns:

UPDATE `yourtable` SET `thecolumn` = 'no' WHERE `keyfield` = <keyvalue> AND `thecolumn` = 'yes'

0
 
LVL 8

Author Comment

by:thenone
ID: 17070591
thanks angel
0
 
LVL 8

Author Comment

by:thenone
ID: 17070592
and if I do not have a primary key?
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17070642
>and if I do not have a primary key?
how do you identify the row to update then?
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17070660
UPDATE `yourtable` SET `thecolumn` = 'no' WHERE `thecolumn` = 'yes'

This will update everything - regardless of the id
0
 
LVL 8

Author Comment

by:thenone
ID: 17073422
and if I was doing it with a recordset?
0
 
LVL 8

Author Comment

by:thenone
ID: 17076756
ok so if I have a recordset where it is rs.open"select * from table1 where column=no"

then when I am looping through my records how can I have the recordset be able to change that column one at a time from no to yes.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17077065
rs.open "select * from table1 where column=no"
while not rs.eof
   rs.fields("column").value = "yes"
   rs.update
   rs.movenext
wend
rs.close
0
 
LVL 8

Author Comment

by:thenone
ID: 17077115
so just this?

rs.fields("column").value = "yes"

ok thanks.
0
 
LVL 9

Accepted Solution

by:
lojk earned 250 total points
ID: 17080983
you would generally never do such a thing... It causes all sorts of record locking issues for starters not to mention the fact that it is *slow*

you would already have dimmed a connection to connect your rs anyway, so why not just do..

dim MyConn as new adodb.connection
myconn=whatever
myconn.execute ("UPDATE `yourtable` SET `thecolumn` = 'no' WHERE `keyfield` = <keyvalue> AND `thecolumn` = 'yes' ")

as angel had already posted?


also, if your DB is access and this is a boolean field rather than text (as it should be) you may actually need to do...

rs.fields("column").value = true


0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month7 days, 1 hour left to enroll

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question