• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MySQL Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MySQL Question


  • Subject: Re: MySQL Question
  • From: Bastiaan Boertien <email@hidden>
  • Date: Mon, 1 Aug 2005 10:11:23 +0200

Hi List


syntax should be INSERT INTO itemstatus (id) VALUES (67) - no single quotes.

The id is the column name from the table. This name may not contain spaces and I think that is the reason that you should not use single quotes. The value need single quotes because there can be spaces in the values.


For a` reference to a column I prefer it more like this tablename.columnname. If you use this for pointing to an column, then you could also call column names in different tables.

Table age
myIndex	age
1		0-10
2		11-23
3		24-40
4		41-60
5		older than 60

Table sex
myIndex 	sex
1		male
2		female

Table person
myIndex	name	backname 	age 		sex
1		Super	Mario		2		1
2		......		.......

As you see there are three tables now and with one SELECT command I would like to have the values of these three tables. This is why I use MySQL

in applescript:

property MySQLEXEC : "/usr/local/mysql/bin/./mysql -h server -u root -ppassword -D Database -e "

set theQuery to "SELECT person.name, person.backname, sex.sex, age.age FROM person, age, sex WHERE person.sex = sex.myIndex AND person.age = age.myIndex and person.name like '%up%'"
set theList to getResultAsList(theQuery)


on GetResultAsList(theQuery)
set applescript's text item delimiters to return
set theResult to every text item of (do shell script MySQLEXEC & (quoted form of (theQuery & " --disable-column-names")))
set applescript's text item delimiters to ""
return theResult
end GetResultAsList


result= Super	Mario	11-23	male

This all were only a few tips. Good luck

greetings bastiaan

Op 27-jul-05 om 20:22 heeft Steve Suranie het volgende geschreven:

<sheepish grin>
typical, I send a help request and ten seconds later I figure it out, the
Doh!
</sheepish grin>



On 7/27/05 2:19 PM, "Steve Suranie" <email@hidden> wrote:

Hi all

I've been toying with this script, the basis of which I got from the Yarra
Valley Software AppleScript mysql interface freeware. All works fine when
reading from the database but when trying to create a new record I get an
error message saying I have a MySQL syntax error. Here's the script:


==============================

set mySQLList to {"/usr/local/mysql/bin/", "/Library/MySQL/bin/"}

repeat with i from 1 to the count of mySQLList
try
set theResult to do shell script (item i of mySQLList) & "mysql -V"
set gPathToMySQL to (item i of mySQLList)
set haveFound to true
exit repeat
end try
end repeat


set gmySQLCommand to gPathToMySQL & "mysql"


set theHost to "10.1.1.###" set theUser to "mysqladmin" set thePassword to "******" set thePort to "3306" set theDatabase to "storeStatus" set theTable to "itemStatus"

set theLoginString to " -h " & theHost & " -u " & theUser & " --password="
& thePassword
set dataBaseString to " -D " & "'" & theDatabase & "'"
set theCommand to gmySQLCommand & theLoginString & dataBaseString & " -e \""
& "SELECT * FROM itemstatus" & "\""
set theResult to ""


--display dialog theCommand
try
    set theResult to do shell script theCommand
on error errMsg
    display dialog errMsg
end try
return theResult

============================

running it as such returns all the records, I can also do a WHERE x = "y"
AND x2 = "y2" and get the right results. But when I change the SQL command
to INSERT INTO itemstatus ('id') VALUES ('67') I get the syntax error. Any
help would be appreciated.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Next by Date: Re: find last row in excel
  • Next by thread: Re: find last row in excel
  • Index(es):
    • Date
    • Thread