Learn SQL with ChatGPT or when can ChatGPT really help

Learn SQL with ChatGPT or when can ChatGPT really help

Postby frose » Fri Nov 17, 2023 7:38 am

I tried the following in SQL
Code: Select all  Expand view  RUN
SELECT * from vll_term WHERE WORT LIKE '%' + UNHEX('C39F') + '%'

The result is not as expected, maybe there is something wrong with the syntax?

The Google answer is:
Image

ChatGPT:
Image

The correct syntax is therefore:
Code: Select all  Expand view  RUN
SELECT * FROM vll_term WHERE WORT LIKE CONCAT('%', UNHEX('C39F'), '%');

The answer was very helpful for me :D
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: Learn SQL with ChatGPT or when can ChatGPT really help

Postby Enrico Maria Giordano » Fri Nov 17, 2023 9:20 am

I can't believe that one would want to use such a totally non-standard SQL statement. What if you want to switch SQL engine in the future (most likely)? I recommend to ever use plain standard SQL.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Learn SQL with ChatGPT or when can ChatGPT really help

Postby frose » Fri Nov 17, 2023 10:00 am

Enrico,
THX for this helpful information, the rest I've done with ChatGPT :wink: :
Image

For users who are in an UTF8 environment it's simple:
Code: Select all  Expand view  RUN
SELECT * FROM vll_term WHERE WORT LIKE '%ß%');
 
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: Learn SQL with ChatGPT or when can ChatGPT really help

Postby Enrico Maria Giordano » Fri Nov 17, 2023 10:11 am

frose wrote:
Code: Select all  Expand view  RUN
SELECT * FROM vll_term WHERE WORT LIKE '%ß%')


That's it! :-)
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Learn SQL with ChatGPT or when can ChatGPT really help

Postby frose » Fri Nov 17, 2023 10:24 am

Enrico,

yes and
Code: Select all  Expand view  RUN
SELECT * FROM vll_term WHERE WORT LIKE CONCAT('%', _utf8'\u00DF', '%');

doesn't work. ChatGPT has obviously made a mistake here.

But when I want to use hex codes for the search string, MariaDB has HEX() and UNHEX().
What is the equivalent in plain SQL?

ChatGPT says:
Certainly, if you're constrained to plain SQL without access to specific MariaDB functions like HEX() and UNHEX(), performing character matching using UTF-8 hexadecimal representations directly within a LIKE statement becomes challenging...

... Unfortunately, in plain SQL without access to database-specific functions, performing character matching using UTF-8 hexadecimal representations directly within LIKE might not be feasible.
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: Learn SQL with ChatGPT or when can ChatGPT really help

Postby Enrico Maria Giordano » Fri Nov 17, 2023 10:27 am

frose wrote:But when I want to use hex codes for the search string, MariaDB has HEX() and UNHEX().
What is the equivalent in plain SQL?


Why do you want to use hex codes for the search string? This is the first question you have to answer.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Learn SQL with ChatGPT or when can ChatGPT really help

Postby frose » Fri Nov 17, 2023 11:06 am

Enrico,

in German we have a saying: 'you are rowing back' 8)
So we can assume that there ist non corresponding construct in plain SQL! :(
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: Learn SQL with ChatGPT or when can ChatGPT really help

Postby Rick Lipkin » Fri Nov 17, 2023 5:30 pm

A little AI joke to make you laugh ...

"Open the Pod Bay Doors Hal" .. Sorry Dave, I can't do that"

Gota love it ... Rick
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Learn SQL with ChatGPT or when can ChatGPT really help

Postby frose » Fri Nov 17, 2023 10:49 pm

ChatGPT cannot (yet) do this, HAL could have done it back in 1968
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: Learn SQL with ChatGPT or when can ChatGPT really help

Postby frose » Sat Nov 18, 2023 5:52 am

Ok, the movie takes place in 2001.

22 years later than Arthur C. Clarks predicted, it becomes reality for evveryone (HA user):
https://hackaday.com/2022/04/23/2022-sci-fi-contest-your-home-assistant-hal-9000/
https://www.home-assistant.io/integrations/openai_conversation/

The I can say 'Ok Google (HAL), please unlock the front door' and Google (HAL) answers...
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests