0

I have a dynamic temp table which columns are id, name, class, x, y, z. Columns other than id, name, class is always changing. The table could be also id, name, class, a, b. The columns other than id, name, class contain numerical values that I need to fetch in order to do some calculation with. I need to fetch all fields except id, name, class. Is there any way to do it with like DB::table('tname')->select(*)->except('name','id','class')->get(); or perhaps other way? Also for that dynamic temp table there's no model for it. So solutions with model is required is kind of impossible for me.

Is there any way to select all columns except for some of them with like DB::table('tname')->select(*)->except('name','id','class')->get(); or perhaps other way?

  • If you create the temp table, dont you know what the other columns are called? You had to create them somehow! – RiggsFolly Apr 13 '21 at 15:57
  • 1
    Does this answer your question? [How to exclude certains columns while using eloquent](https://stackoverflow.com/questions/23612221/how-to-exclude-certains-columns-while-using-eloquent) – Areg Apr 13 '21 at 16:09
  • Taking a step back, do you really need to not have these columns? Does your code break if they exist in your dataset, or are you trying to perform some optimization? – Chris Haas Apr 13 '21 at 16:12

0 Answers0