laravel where query on attributes
My database schema:
id|user_id|choosen_number|win_number
1|2|5|7
2|2|7|7
My query:
Withdrawal::where('user_id', 2)->where('choosen_number', 'win_number')->get()
for some reason the returned collection is empty all the time. Any idea?
Your query finds a record with "win_number" string value in "choosen_number" column, not does not compare this columns.
If you want to compare 2 columns you must use whereColumn clause:
Withdrawal::where('user_id', 2)->whereColumn('choosen_number', 'win_number')->get();
what are you trying to do?
right now r searching for text 'win_number' in 'choosen_number' column which wont work..
you need to use 'like' function of sql...
storing more than 1 numb per col is not a good idea
Please or to participate in this conversation.