0

I have a mySQL database which I've connected to through google sheets using JDBC. In my spreadsheet, I have a list of hashtags and number of times which that hashtag was mentioned that day. Each one of these hashtags is already stored in a table in the databse.

When I try to query the Integar value for a specific hashtags ID number - the value returns as 'true' instead of returning as a number.

If I run the same query outside of app script - it returns the number? I don't understand why. I've tried messing around with the syntax but nothing helps.

.

The spreadsheet is layed out:

Col A: Hashtag

Col B: Number times mentioned

.

The table in the Database is:

Col 1: Hashtag_ID (Int / PK)

Col 2: Hashtag (VarChar)

.

The idea is to track hastag mentions daily.

I'm really stuck with this. It makes no sense.

Thanks in advance.

var conn = Jdbc.getCloudSqlConnection(dbUrl, user, userPwd); //JDBC connection to DB

var Htag = sheet.getRange('A2').getValue(); //String - Hashtag Text

var HashtagID = conn.createStatement().execute('SELECT id FROM HashtagTable WHERE Hashtag = "'+ Htag + '"');

Logger.log('Hashtag ID Number: ' + HashtagID); //Outputs result of query
ABB1987
  • 95
  • 6
  • It would help if you add comments in your code to indicate what the variables actually output – Neven Subotic Oct 17 '21 at 17:30
  • Did you understand what Mark said? https://stackoverflow.com/questions/69605961/google-app-script-mysql-query-returns-boolean-true-instead-of-integer#comment123032290_69605961 If not, try asking for clarification. – TheMaster Oct 17 '21 at 17:31
  • A little but no not really. I tried executeQuery and got resultset as output. I don't really code so i'm struggling to work out how to use it. I'll be spending a few more hours with doctor google. TheMaster – ABB1987 Oct 17 '21 at 17:37
  • Try Read database sample [here](https://developers.google.com/apps-script/guides/jdbc?hl=en#read_from_the_database) – TheMaster Oct 17 '21 at 17:48
  • 1
    Got It to work guys Thanks – ABB1987 Oct 17 '21 at 18:27

0 Answers0