Clyatt: Naftilos76: Forget about CAST then :
Salceda: Kamuela: Sorry, I have no idea about that manual entry.
Treml: I’m trying to query MySQL via PHP to get all columns in a table except 3 in a 46 column table. Is there a good way to do it with a single query? I googled for ways but they all use a couple of queries, which isn’t a problem if that’s the way to do it
Nugent: SirLagz: You need to use the names of all columns except the ones you do not want.
Nugent: This is best practice anyway, even in situations where you want all columns i.e. it’s bad practice to use SELECT * in your code
Bizarro: Nugent: damn, guess I better get started typing them all out heh
Nugent: This protects your code against future changes in the table schema number, order, names of columns because it gives an explicit error message instead of simply running and pushing the error a few lines ahead
Syck: Nugent: and I guess I should stop using SELECT * too
Nugent: In general that’s a good idea yes :
Cobane: Nugent: thanks for your help
Xiong: Nugent: evil is clearly defined at http://www.p****error.com/sql/select*isevil.html # To get all column names: EXPLAIN EXTENDED SELECT * FROM yourtable; SHOW WARNINGS;
Clyatt: Nugent: In case you don’t know that article. It is good to show to people when explainng why SELECT * is bad
Clyatt: SirLagz: If I see a table wtih 46 columns I would suspect the database is not designed well
Alvarracin: Salle: thanks for that link
Mordeci: Salle: also, why would 46 columns be a database not designed well?
Crumlish: Salle: I guess I could split this up into 2 different tables now that I think about it.
Nugent: SirLagz: it’s often an indicator that your table contains information about more than one “thing”
Nugent: Which in turn suggests it’s not normalized
Ehrich: Nugent: yeah the whole coode?’s law and all,
Cadice: This table is just for a checklist
Mackey: Actually this should have been split into 3 tables now that I think about it.oops
Scouten: But then it’d still be 20 columns in 2 of the tables.would that still be “too many columns” ?
Nugent: There are situations when 46 or 460 columns in a table might still be a good design
Elton: Nugent: guess it’d depend on the situation then
Nugent: Absolutely. If you are confident you understand normalization, then you’ll probably understand when each column belongs in that table
Vanatta: Nugent: I’m confident I understand normalisation.but when I’m doing stuff at 5 in the morning, I forget haha
Nugent: If not, then it’s a good idea to get your head around what key dependencies are, and what that means for each column in a table
Nast: This table with 46 columns is for a checklist, car, model, item1, item1 comment, item2.item 44, item 44 comment
Nugent: A m***ively simplified version: Each column in a table should contain a single piece of information about the thing identified by that table’s key
Clyatt: SirLagz: You just proved yourself wrong I am afraid
Mazzarella: So it’s all “about the checklist”
Nugent: That’s what’re called “repeating groups”
Clyatt: SirLagz: You don’t really understand the normalization
Pasaye: Salle: I did that particular table at 5 in the morning lol.i mightn’t have been thinking right at the time
Clyatt: SirLagz: Couple of questions: Are these items fixed with zero chance to add or remove some of them any time in the future? Do you always set all of them for each entry or some can remain unknown?
Simoncini: Salle: only just started working on this again and thought.hang on.this seems like it’s done wrong
Natsis: Salle: I’ve been told these items aren’t going to change, and they’re all set for each entry
Clyatt: SirLagz: With cars I really doubt that :
Deglanville: Salle: haha, it’s a pretty general checklist. unless they remove headlights, tail lights, or seatbelts from the car, I don’t think it’s going to change