eMonk Posted April 26, 2011 Share Posted April 26, 2011 One of my tables has 28 columns. I'm going to be echoing 9 of the columns in my index file. Which of the following queries would be better to do this as they both work: $query = "SELECT * FROM model"; $query = "SELECT column1, column2, column3, column4, .... FROM model"; Link to comment https://forums.phpfreaks.com/topic/234774-select-question/ Share on other sites More sharing options...
eMonk Posted April 26, 2011 Author Share Posted April 26, 2011 Guess I'll go with $query = "SELECT column1, column2, column3, column4, .... FROM model"; because it makes more sense and just fetches the data I'll be using. The first query is just smaller code so I was wondering which would be better but after some thought I think the second one would be better unless someone else says otherwise. Link to comment https://forums.phpfreaks.com/topic/234774-select-question/#findComment-1206552 Share on other sites More sharing options...
Pikachu2000 Posted April 26, 2011 Share Posted April 26, 2011 As a general rule, it's always better to name the fields explicitly rather than use a wildcard *, so yes, the second one IMO. Link to comment https://forums.phpfreaks.com/topic/234774-select-question/#findComment-1206557 Share on other sites More sharing options...
ManiacDan Posted April 26, 2011 Share Posted April 26, 2011 As an aside: If your column names are actually "column1" "column2" etc, you're doing it wrong. -Dan Link to comment https://forums.phpfreaks.com/topic/234774-select-question/#findComment-1206563 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.