4 Replies - 229 Views - Last Post: 07 July 2013 - 02:15 AM Rate Topic: -----

#1 brerallia  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 146
  • Joined: 21-January 13

Is it possible to query and set a value?

Posted 04 July 2013 - 07:00 PM

hello... i am trying to figure it out how to set a value after i query..

there are 2 types of students; boys and girls so they all belong to student.
i query separately the list of boys and girls;
so the boys will have allowance of 500
while the girls will have an allowance of 1000

i had the query right in getting the list of all boys name and girls name.. no how am i going to set a value in their allowance.. i mean.. you may think it is insane but i need to store their allowance...

is it like
select name
from students
where student_type = 'boys' and give value to allowanct = 500??


is that right?

Is This A Good Question/Topic? 0
  • +

Replies To: Is it possible to query and set a value?

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9094
  • View blog
  • Posts: 34,148
  • Joined: 12-June 08

Re: Is it possible to query and set a value?

Posted 04 July 2013 - 10:57 PM

No, you would either use the results as a join, or in an 'in' on the WS hwhere clause.
Was This Post Helpful? 0
  • +
  • -

#3 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 795
  • View blog
  • Posts: 1,681
  • Joined: 30-January 09

Re: Is it possible to query and set a value?

Posted 04 July 2013 - 11:36 PM

I think what you're after in an UPDATE query, like so:
UPDATE students SET
    allowance = 500
WHERE student_type = 'boys'


If you want to return the name of each affected row after that, doing so depends on the database engine you're using.
Was This Post Helpful? 0
  • +
  • -

#4 brerallia  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 146
  • Joined: 21-January 13

Re: Is it possible to query and set a value?

Posted 07 July 2013 - 01:40 AM

View Poste_i_pi, on 04 July 2013 - 11:36 PM, said:

I think what you're after in an UPDATE query, like so:
UPDATE students SET
    allowance = 500
WHERE student_type = 'boys'


If you want to return the name of each affected row after that, doing so depends on the database engine you're using.


i tried to query that... but it says error...
"no column allowance exist, doesnt affect it."
do i need to add an attribute allowance in it??? but i just need to set a value in it..
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3362
  • View blog
  • Posts: 11,399
  • Joined: 12-December 12

Re: Is it possible to query and set a value?

Posted 07 July 2013 - 02:15 AM

If the error message says "no column allowance exists" then it couldn't be much clearer. You need a column in the table in order to UPDATE it. I also notice a different spelling allowanct in your first post.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1