Page 1 of 1

variable into mysql

Posted: Wed May 21, 2014 8:00 am
by Theoleen
I am a newby so
i want to update or search a record in mysql.
if i put in something like SELECT * FROM table WHERE score=12 or name="theo" it works ; score and name are columns in mysql
But i want to ask the input first, put it into a variable, how do i put the content of that variable in mysql?

theo

Re: variable into mysql

Posted: Wed May 21, 2014 10:47 am
by Klaus
Hi Theo,

1. welcome to the forum! :D

2. You need to build the correct string!
Example:
...
put 12 into tNumber
put "SELECT * FROM table WHERE score=" & tNumber into tSQL
...
Check this thread about exactly this topic:
http://forums.runrev.com/phpBB2/viewtop ... 12&t=20360


Best

Klaus

Re: variable into mysql

Posted: Tue May 27, 2014 8:24 pm
by Theoleen
Thanks for your reply
That works with a digit into tNumber but not if i put a text into tNumber.
I want to search for a record of a person by asking his name. Then search for the record.


theo

Re: variable into mysql

Posted: Tue May 27, 2014 8:43 pm
by Klaus
Hi Theo,

why did you not take a look at the thread I posted? :shock:
You really should do!

This is what I wrote there:
...
put field "saisie" into champsaisie
put "INSERT into informations_table VALUES ('" & champsaisie & "');" into tSQL
...

This is just an example, but I am sure you can change this to the SELECT statement
for your needs 8)


Best

Klaus