Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

SQLITE fields

Options
  • 14-09-2011 12:45pm
    #1
    Registered Users 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 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 Posts: 11,979 ✭✭✭✭Giblet


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


  • Registered Users Posts: 91 ✭✭keithrus


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


  • Registered Users 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 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 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