sql - mySQL query doesnt work as expected -


i have 2 tables in database :

users ------ id deviceid os pushtoken 

and

subscription ------ deviceid pushtoken 

when user needs subscribed in subscription table , only "gives" me deviceid. statement add deviceid , pushtoken table :

$stmt = $db->prepare("insert subscription(deviceid,pushtoken)                         select deviceid , pushtoken users  deviceid = :deviceid"); $stmt->execute(array(':deviceid' => $deviceid)); 

this works , able pushtoken users table , write in subscriptions table.

however later noticed dont want have deviceid in subscription table. need have os . subscription table looks this:

subscription ------ os pushtoken 

with same logic before , when user passes me deviceid want able subscribe him new table. wrote statement:

$stmt = $db->prepare("insert subscription(os,pushtoken)                         select os , pushtoken users  deviceid = :deviceid"); $stmt->execute(array(':deviceid' => $deviceid)); 

however time , cant insert work ! dont error..

what wrong here?

edit


i started understand problem , dont know how fix though. getting error , error :

pdoexception error: sqlstate[42s22]: column not found: 1054 unknown column 'deviceudid' in 'where clause' 

why though?

all want os , pushtoken user table deviceid in table specific one. how can write query?

also nice know why query wrote wrong... doesnt make sense me.

obviusly 0 rows because using os parameter @ condition deviceid where deviceid = :deviceid have change column. mean have change where os = :deviceid

update

also, avoid missunderstanding change :deviceid :os if possible.


Comments