Create Table MySQL

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Quinton B.
Posts: 108
Joined: Mon Mar 20, 2017 5:13 am

Create Table MySQL

Post by Quinton B. » Wed Apr 03, 2019 4:23 am

Good day, I'm trying to create a table in a MySQL database with the following code:

Code: Select all

put "CREATE TABLE IF NOT EXISTS PAV2_ACCOUNTS (User_ID int(50) NOT NULL auto_incriment, User_Name varchar(50) NOT NULL, Password varchar(50) NOT NULL, Authentication_Code varchar(50) NOT NULL, DoD_Email varchar(50) NOT NULL, DSN varchar(50) NOT NULL, Personell_Number varchar(50) NOT NULL, Address varchar(100) NOT NULL, Security_Question_1 varchar(100) NOT NULL, Security_Answer_1 varchar(100) NOT NULL, Security_Question_2 varchar(100) NOT NULL, Security_Answer_2 varchar(100) NOT NULL, Security_Question_3 varchar(100) NOT NULL, Security_Answer_3 varchar(100) NOT NULL, Picture blob(), Privilages varchar(100), Branch varchar(4) NOT NULL, Duty_Code varchar(10) NOT NULL, Duty_Status varchar(2) NOT NULL, Rank varchar(15) NOT NULL, MAJCOM varchar(20) NOT NULL, Base varchar(100) NOT NULL, Group varchar(100) NOT NULL, Squadron varchar(100) NOT NULL, Flight varchar(100) NOT NULL, Position varchar(100), Additional_Position varchar(100), PRIMARY KEY(User_ID)" into tSQL
   revExecuteSQL gConnectionID, tSQL
The above code status a code that something is wrong with how it is worded, I have no idea what is wrong with it.

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Create Table MySQL

Post by Klaus » Wed Apr 03, 2019 7:56 am

Hi Quinton,

looks like there is no closing bracket at the end.

Code: Select all

...
## put "CREATE TABLE IF NOT EXISTS PAV2_ACCOUNTS (User_ID int(50) NOT NULL...PRIMARY KEY(User_ID)" into tSQL
put "CREATE TABLE IF NOT EXISTS PAV2_ACCOUNTS (User_ID int(50) NOT NULL...PRIMARY KEY(User_ID))" into tSQL
...
Best

Klaus

Quinton B.
Posts: 108
Joined: Mon Mar 20, 2017 5:13 am

Re: Create Table MySQL

Post by Quinton B. » Wed Apr 03, 2019 5:26 pm

I'm still getting the same error regardless of the forgotten parentheses.
Attachments
Untitled.png
Untitled.png (11.69 KiB) Viewed 4904 times

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Create Table MySQL

Post by Klaus » Wed Apr 03, 2019 6:23 pm

Hm, I can spot a typo here:
... (User_ID int(50) NOT NULL auto_incriment
But then my SQL kowledge leaves me...

Quinton B.
Posts: 108
Joined: Mon Mar 20, 2017 5:13 am

Re: Create Table MySQL

Post by Quinton B. » Wed Apr 03, 2019 9:01 pm

Well, it fixed all the way up to this part.
Attachments
Untitled1.png
Untitled1.png (11.42 KiB) Viewed 4877 times

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Create Table MySQL

Post by Klaus » Wed Apr 03, 2019 9:10 pm

Hm, Group is maybe a "reseved" word in the mariaDB engine? SQL -> group by...

And/or maybe you need to QUOTE the names?
I have two little functions for exactly this purpose :D

Code: Select all

## Add quotes "
function q tString
  return QUOTE & tString & QUOTE
end q

## Add single quotes '
function q2 tString
  return "'" & tString & "'"
end q

Quinton B.
Posts: 108
Joined: Mon Mar 20, 2017 5:13 am

Re: Create Table MySQL

Post by Quinton B. » Thu Apr 04, 2019 12:47 am

I was able to create it by changing the name group to something else.

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Create Table MySQL

Post by Klaus » Thu Apr 04, 2019 3:45 am

Quinton B. wrote:
Thu Apr 04, 2019 12:47 am
I was able to create it by changing the name group to something else.
Great!

Post Reply