sql - SQLite subquery not working in PHP -


I am working on a simple voting system, I am preparing a complete scenario using php and sqlite and It has been tested in the scalet command line, where it worked well but a question for which all the possible answers to the voting should be returned and the users who vote for it do not work anymore ... < / P>

Tables:

  selected table Create question (CHAR (200)); Create table option (poll_id INTEGER (5), option_text CRAR (200)); Create table users (name CHAR (100), pass (100), session CHAR (100), create table users (poll_id INTEGER (5), user_id INTEGER (5), like_id INTEGER (5), primary key (poll_id, user_id) );  

PHP:

  $ query = "SELECT choices.rowid, options.choice_text, (select from users users) .name WHERE votes.user_id = users.rowid) Leave the names, options on the selection, vote on elections. Arrow = votes.choice_id WHERE polls.rowid = options.poll_id and polls.rowid = '$ pollid' " ; $ Result = $ db- & gt; array ($ query, SQLITE_ASSOC); echo json_encode ($ result);  

This return:

  Note: SQLiteDatabase :: arrayQuery () [sqlitedatabase.arrayquery]: There are no such columns: Users in C.  

The first time I tried that

  (Choose from users.name.name, votes to WHERE vote.user_id = users.troid) AS name  

This works, but does not return the same result: / I am very long with that question, because I am not a professional, so I think there may be better questions for this too?

If I correctly interpret your query, then you can avoid the subquery and simultaneously Can join. You do not need to select from elections . Choose

  option. Options, options. Chias_text, user. Choose fewer options than the name option but choose votes. Arrow = Vote. Vote on Choice_ID votes to users. User-id = users.Road ou choice. Poll_id =?  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -