0

I am trying to use str_to_date function with mysql but I want to do this through a shell. I have found the -e parameter and I tried to do it by assigning a variable number from the outside in the loop but it works but the sql syntax error can be corrected. delirium if you indicate an error in my explanations

MY CODES

#!/bin/bash
kullanici='burak';
sifre='testdb';
tablo='testtab';
echo -n 'Lutfen gununu sayi olarak girin (orn 24) : '
read gununu
echo -n 'Lutfen zaman aralıgının kactan baslayacagını girin (orn 8) : '
read kactan
echo -n 'Lutfen zaman araligini kacar kacar artacagını girin (orn 15) : '
read kacar
echo -n 'Lutfen kacta bitecegini girin (orn 45) : '
read bitecegini
echo -n 'Lutfen girise baslanacak saati girin (orn 9) : '
read saati
echo -n 'Lutfen eklenecek sektör kodunu girin (orn 1012101) : '
read eklenecek
tbl=$tablo
for (( i=$kactan; i<=$bitecegini; i=i+$kacar )); do
## SQL PROMPT ##
mysql -u $kullanici -p$sifre -D u8184144_data  -e "INSERT INTO '$tablo'('poliklinik_kodu', 'randevu_bas') VALUES ($eklenecek,str_to_date('$gununu 2018 $saati $kacar','%d %M %Y %H %i'));"
done

note: why can not I add it with the -e parameter? :)

buraks
  • 1
  • 1
  • Read this: [When to use single quotes, double quotes, and back ticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-back-ticks-in-mysql) – fancyPants Jul 26 '18 at 07:38
  • Thanks a lot for the syntax problem, but now I can not add a change to the other problem database. According to the source you provided, the new editing and code works current code "INSERT INTO $tablo(poliklinik_kodu,randevu_bas) VALUES ('$eklenecek',str_to_date('$gununu' '2018' '$saati' '$kacar','%d %M %Y %H %i'));" but Do you have any idea on this issue when you insert the current values into the table do not register the table? :) – buraks Jul 26 '18 at 08:57

0 Answers0