FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Learn SQL with ChatGPT or when can ChatGPT really help
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Learn SQL with ChatGPT or when can ChatGPT really help
Posted: Fri Nov 17, 2023 07:38 AM
I tried the following in SQL
Code (fw): Select all Collapse
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:


ChatGPT:


The correct syntax is therefore:
Code (fw): Select all Collapse
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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Learn SQL with ChatGPT or when can ChatGPT really help
Posted: Fri Nov 17, 2023 09: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.

Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: Learn SQL with ChatGPT or when can ChatGPT really help
Posted: Fri Nov 17, 2023 10:00 AM
Enrico,
THX for this helpful information, the rest I've done with ChatGPT :wink: :


For users who are in an UTF8 environment it's simple:
Code (fw): Select all Collapse
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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Learn SQL with ChatGPT or when can ChatGPT really help
Posted: Fri Nov 17, 2023 10:11 AM
frose wrote:
Code (fw): Select all Collapse
SELECT * FROM vll_term WHERE WORT LIKE '%รŸ%');
That's it! :-)
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: Learn SQL with ChatGPT or when can ChatGPT really help
Posted: Fri Nov 17, 2023 10:24 AM
Enrico,

yes and
Code (fw): Select all Collapse
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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Learn SQL with ChatGPT or when can ChatGPT really help
Posted: 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.
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: Learn SQL with ChatGPT or when can ChatGPT really help
Posted: 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
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Learn SQL with ChatGPT or when can ChatGPT really help
Posted: Fri Nov 17, 2023 05: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

Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: Learn SQL with ChatGPT or when can ChatGPT really help
Posted: 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
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: Learn SQL with ChatGPT or when can ChatGPT really help
Posted: Sat Nov 18, 2023 05: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

Continue the discussion