Here's my SELECT query:
SELECT col1, col3, col5, col8
FROM Table1
In my SELECT query, I want to perform a COUNT(*) exclusively for the current row.
I want something like this, but have no idea how I can get this:
SELECT col1, col3,
(
SELECT COUNT(*)
FROM table1 WHERE col3 = col3 value for current row
),
col5, col8
FROM Table1
What is the correct way to perform a COUNT(*) for the current row of a SELECT query resultset?
try this:
set @num := 0;
SELECT @num := @num+1 , col1, col3, col5, col8 FROM Table1
or other way:
SET @num := ( SELECT COUNT( * ) FROM Table1) ;
SELECT @num := @num -1 , col1, col3, col5, col8
FROM Table1
SELECT col1, col3,
(
SELECT COUNT(*)
FROM table1 WHERE id = A.Id
) Count,
col5, col8
FROM Table1 A
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With