📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Anyone good with SQL?

24

Comments

  • JohnB47
    JohnB47 Posts: 2,665 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    GDB2222 said:
    Incidentally, I asked ChatGPT your question about the apostophe (what I wrote was just: Fred's Groceries how best to deal with this as the data?) and it suggested:

    WHERE LOWER(REPLACE("Description", '''', '')) LIKE '%freds groceries%';

    I don't use SQL, but it's pretty obvious that that just changes the description to lower case and replaces the apostophe with nothing. 

    I'm not sure whether '''' is right, or it needs an extra'? 
    Thanks. Interesting stuff but a bit beyond me. I prefer a more human interaction - assuming that everyone who replies is actually human. 
  • teaselMay
    teaselMay Posts: 665 Forumite
    500 Posts First Anniversary Name Dropper
    My computer tells me I am regularly
  • JohnB47
    JohnB47 Posts: 2,665 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    I think I'll be onboard with AI in general when it can remind me why I went upstairs.
  • Heedtheadvice
    Heedtheadvice Posts: 2,757 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    edited 6 January at 12:07AM
    Fred's sounds like Freds does it not?

    ...SOUNDEX......?


    To cater for all similar text with punctuation by specific code, you will have to use specific code for each possible case.

    Consider Fred's, Freds, Fred's. Fred's!, Fred"s @Freds Freds_

    etc.

  • Ergates
    Ergates Posts: 3,020 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    GDB2222 said:
    Incidentally, I asked ChatGPT your question about the apostophe (what I wrote was just: Fred's Groceries how best to deal with this as the data?) and it suggested:

    WHERE LOWER(REPLACE("Description", '''', '')) LIKE '%freds groceries%';

    I don't use SQL, but it's pretty obvious that that just changes the description to lower case and replaces the apostophe with nothing. 

    I'm not sure whether '''' is right, or it needs an extra'? 


    WHERE (upper("Description") Like ('%FRED%GROCERIES%'))

    would match "Freds Groceries" and "Fred's Groceries" but also "Fred Groceries" and "Fred should really go and buy some Groceries".  So simpler (in that it uses fewer functions) but you have to know your data.
  • onomatopoeia99
    onomatopoeia99 Posts: 7,152 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    teaselMay said:
    You could always use some regular expressions to ignore the apostrophes if they become a problem


    Confucius says: "Man who try to solve problem with regular expression now man with two problems"
    Proud member of the wokerati, though I don't eat tofu.Home is where my books are.Solar PV 5.2kWp system, SE facing, >1% shading, installed March 2019.Mortgage free July 2023
  • flaneurs_lobster
    flaneurs_lobster Posts: 6,420 Forumite
    Sixth Anniversary 1,000 Posts Photogenic Name Dropper
    Old programmer in me is shouting "get the input data validation tightened up".

    Makes this type of problem unnecessarily hard if the conditional tests can have any old rubbish thrown at them. 
  • victor2
    victor2 Posts: 8,090 Ambassador
    Part of the Furniture 1,000 Posts Name Dropper
    Old programmer in me is shouting "get the input data validation tightened up".

    Makes this type of problem unnecessarily hard if the conditional tests can have any old rubbish thrown at them. 

    But anyone who's developed any software knows there is nothing like a user to test it in ways you had never envisaged! :)

    I’m a Forum Ambassador and I support the Forum Team on the In My Home MoneySaving, Energy and Techie Stuff boards. If you need any help on these boards, do let me know. Please note that Ambassadors are not moderators. Any posts you spot in breach of the Forum Rules should be reported via the report button, or by emailing forumteam@moneysavingexpert.com. 

    All views are my own and not the official line of MoneySavingExpert.

  • Ergates
    Ergates Posts: 3,020 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    victor2 said:
    Old programmer in me is shouting "get the input data validation tightened up".

    Makes this type of problem unnecessarily hard if the conditional tests can have any old rubbish thrown at them. 

    But anyone who's developed any software knows there is nothing like a user to test it in ways you had never envisaged! :)
    As we used to say:  No data load survives first contact with the user.
  • Ergates
    Ergates Posts: 3,020 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Old programmer in me is shouting "get the input data validation tightened up".

    Makes this type of problem unnecessarily hard if the conditional tests can have any old rubbish thrown at them. 
    You can have the source system fixed yesterday, and you can have the source system fixed tomorrow, but you can never have the source system fixed today.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 350.6K Banking & Borrowing
  • 253K Reduce Debt & Boost Income
  • 453.4K Spending & Discounts
  • 243.6K Work, Benefits & Business
  • 598.3K Mortgages, Homes & Bills
  • 176.7K Life & Family
  • 256.7K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.