Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

SQLITE fields

  • 14-09-2011 12:45PM
    #1
    Registered Users, Registered Users 2 Posts: 91 ✭✭


    If a tables 'name' field is the same as one of the tables 'field' in SQLITE should there be any duplication/problems etc??

    I have a table named sb_Market.
    One of this tables name is called 'Handicap'
    One of the fields' is also called 'Handicap' with a value.

    When I make any changes within the 'Handicap' , the name changes to the field value.


Comments

  • Registered Users, Registered Users 2 Posts: 2,021 ✭✭✭ChRoMe


    keithrus wrote: »
    If a tables 'name' field is the same as one of the tables 'field' in SQLITE should there be any duplication/problems etc??

    I have a table named sb_Market.
    One of this tables name is called 'Handicap'
    One of the fields' is also called 'Handicap' with a value.

    When I make any changes within the 'Handicap' , the name changes to the field value.

    It should be fine, can you post what query you are using?


  • Registered Users, Registered Users 2 Posts: 12,025 ✭✭✭✭Giblet


    Are you able to use the fully qualified name? dbname.tablename.column ?


  • Registered Users, Registered Users 2 Posts: 91 ✭✭keithrus


    SELECT * FROM sb_Market WHERE sb_Market.MeetngId=19798 AND sb_Market.EventId=2 AND sb_Market.Name='Handicap';


  • Registered Users, Registered Users 2 Posts: 1,456 ✭✭✭FSL


    Do you not need [] around Name as Name is an attribute and you are also using it as a field name e.g sb_Market.[Name]='Handicap'.

    This is the case in MSSQL.


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    more fundamental why do you have a table and column with the same name?

    Would the table handicap be better named as playerhandicap, personhandicap etc?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 91 ✭✭keithrus


    Resolve found.

    Its how SQLITE handles and recognises double and single quotes on an update.

    Apparently, this is done on an update to the DB
    UPDATE sb_Market SET Name=”Handicap” WHERE...

    This works fine, unless there happens to be a field in the table called “Handicap”, in which case the value of this field rather than the text “Handicap” are inserted.

    The correct update statement should look like this:



    UPDATE sb_Market SET Name=’Handicap’ WHERE...


Advertisement