Page 1 of 1
how to do a search in MySQL table?
Posted: Fri Jul 08, 2011 6:05 am
by jmjared
Hi everyone,
I've been trying to be able to search for certain words in MySQL table and get the words that match the search criteria into a field...
any help would really be appreciated (i'm about to kill myself with this...)
Thanks!!!
JM
Re: how to do a search in MySQL table?
Posted: Fri Jul 08, 2011 7:12 am
by bangkok
You should find a lot of examples (working scripts) on this forum.
Or post your current script so we can have a look.
Re: how to do a search in MySQL table?
Posted: Fri Jul 08, 2011 8:55 am
by jmjared
Thanks..
This is what I have so far..
global gConnectionID
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
put "SELECT event FROM postings" into tSQL
put revDataFromQuery(tab, cr, gConnectionID, tSQL,) into tData
if item 1 of tData = "postings" then
answer error "There was a problem quering the database:" & cr & tData
else
put tData into field "SEARCH LIST"
end if
I'm able to get a column from the table but I want to be able to search for specific items within the column and make those the only one to show on the field..
Re: how to do a search in MySQL table?
Posted: Fri Jul 08, 2011 9:59 am
by SparkOut
It depends on the size of the data that is returned I suppose, but you may find that Livecode, with its excellent text chunk handling makes as good a job of extracting the data you want to display from the values returned in the tData variable than it would be to filter the data in the SQL query. Nevertheless, there is no point in needlessly bottlenecking the application by returning unwanted data so you probably want to have your SQL query something like:
Code: Select all
put "birthday" into tEvent -- or whatever text you are looking to match
put "SELECT event FROM postings WHERE event LIKE '%" & tEvent & "%'" into tSQL
The result should be a SQL query that looks like:
SELECT event FROM postings WHERE event LIKE '%birthday%' and will return data from records where the event column contains the word "birthday" at any point in the string.
Re: how to do a search in MySQL table?
Posted: Fri Jul 08, 2011 1:54 pm
by Klaus
Hi JM,
looks like you need to learn a little SQL!
Check this, which also got me started with SQL
http://www.w3schools.com/sql/default.asp
Best
Klaus
Re: how to do a search in MySQL table?
Posted: Wed Jul 13, 2011 9:34 am
by jmjared
awesome! that was very helpful... THANKS!