Your subquery is selecting two columns, while you are using it to project one column (as part of the outer SELECT
clause). You can only select one column from such a query in this context.
Consider joining to the users
table instead; this will give you more flexibility when selecting what columns you want from users
.
SELECT topics.id, topics.name, topics.post_count, topics.view_count, COUNT( posts.solved_post ) AS solved_post, users.username AS posted_by, users.id AS posted_by_id FROM topics LEFT OUTER JOIN posts ON posts.topic_id = topics.id LEFT OUTER JOIN users ON users.id = posts.posted_by WHERE topics.cat_id = :cat GROUP BY topics.id
Related Posts:
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- Unknown column in ‘field list’ error on MySQL Update query
- Unknown column in ‘field list’ error on MySQL Update query
- MySQL “CREATE TABLE IF NOT EXISTS” -> Error 1050
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- MySQL create table if not exists and insert record only if table was created
- How do I use properly CASE..WHEN in MySQL
- How can I do a FULL OUTER JOIN in MySQL?
- MySQL query String contains
- What’s the difference between VARCHAR and CHAR?
- Case statement in MySQL
- How to declare a variable in MySQL?
- MySQL Cannot Add Foreign Key Constraint
- How to split the name string in mysql?
- How do I import an SQL file using the command line in MySQL?
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
- mysql Foreign key constraint is incorrectly formed error
- MySQL: Invalid use of group function
- How can I return pivot table output in MySQL?
- Compare dates in MySQL
- MySQL “WITH” clause
- MySQL Multiple Joins in one query?
- Error Code: 2013. Lost connection to MySQL server during query
- MySQL syntax for Join Update
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
- how to drop partition without dropping data in MySQL?
- MySQL combine two columns into one column
- Simple way to calculate median with MySQL
- Error 1046 No database Selected, how to resolve?
- MySQL Error 1264: out of range value for column
- Remove duplicate rows in MySQL
- How to SUM and SUBTRACT using SQL?
- Cast from VARCHAR to INT – MySQL
- SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax — PHP — PDO [duplicate]
- How do you force mysql LIKE to be case sensitive?
- MySQL – UPDATE multiple rows with different values in one query
- How to create a MySQL hierarchical recursive query?
- ERROR 1148: The used command is not allowed with this MySQL version
- Insert into a MySQL table or update if exists
- How to round down to nearest integer in MySQL?
- MySQL starts with searching issue
- Query to convert from datetime to date mysql
- Is it possible to GROUP BY multiple columns using MySQL?
- MySQL error: key specification without a key length
- Best way to test if a row exists in a MySQL table
- Check if MySQL table exists without using “select from” syntax?
- MySQL equivalent of DECODE function in Oracle
- mysql update column with value from another table
- The used SELECT statements have a different number of columns
- How to delete from multiple tables in MySQL?
- MySQL: Can’t create table (errno: 150)
- How to copy a row and insert in same table with a autoincrement field in MySQL?
- Join vs. sub-query
- Alternative to except in MySQL
- Equivalent of explode() to work with strings in MySQL
- ROW_NUMBER() in MySQ
- MySQL OPTIMIZE all tables?
- MySQL INSERT INTO table VALUES.. vs INSERT INTO table SET
- MySQL – Get row number on select
- MySQL error: Unknown column in ‘where clause’
- How to truncate the text returned for a column in a MySQL query
- Using union and order by clause in mysql
- MySQL LIKE IN()?
- What is a stored procedure?
- ORA-00907: missing right parenthesis
- Rename column SQL Server 2008
- Teradata: how to convert varchar value (format ‘dd.mm.yyyy’) to date (format ‘yyyy-mm-dd’ )?
- How Stuff and ‘For Xml Path’ work in SQL Server?
- Oracle SELECT TOP 10 records
- What is the definition of cardinality in SQL
- must appear in the GROUP BY clause or be used in an aggregate function
- The multi-part identifier could not be bound
- PDO with INSERT INTO through prepared statements
- Selecting data from two different tables without using joins
- SQLite – UPSERT *not* INSERT or REPLACE
- Creating a search form in PHP to search a database?
- The ALTER TABLE statement conflicted with the FOREIGN KEY constraint
- What is it exactly a BLOB in a DBMS context
- Simple Random Samples from a Sql database
- What does SQL clause “GROUP BY 1” mean?
- SELECT DISTINCT on one column
- SQL select only rows with max value on a column
- Microsoft OLE DB Provider for SQL Server error ‘80004005’
- Equivalent of Oracle’s RowID in SQL Server
- Subtract one day from datetime
- updating table rows in postgres using subquery
- Is merge statement available in MySQL
- Filter data based on date in sql
- SQL query to extract only the “current” wp_posts?
- How to retrieve sticky post in raw sql?
- How to remove in the wordpress database all posts revisions except the last three?
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- Backticks (`) Instead of Single Quotes (‘) in an SQL Statement?
- Query WordPress database by registered date and role
- Why this query is not showing any result on wordpresss home page?
- making php value numeric
- Unknown column ‘wp_posts.ID’ in ‘field list
- Improving performance of SQL sub-queries in WordPress
- How to get EVENT based on startday, using BETWEEN
- Possible SQL injection. How to locate and fix?