Background
I have a large table with lots of values and want to check if any of the names are repeating and only display those results. I have built a view and cannot get the SQL query to return the result I want.
Code
Here is the code as it stands, I've done loads of variations of it but cant get the result and think that there must be a core problem with my logic.
So I have built a view and selected a couple of column and now I want a column that will print out the name of the title the number of times it appears in the database. Or just count the number and print that.
<?php
$value = $row->title;
$query= "SELECT node.title, node.type
FROM {node} node
WHERE (node.type IN ('institution')
AND node.title =".$value.")";
$result= db_query($query);
$wat = $result->fetchAll(PDO::FETCH_COLUMN, 0);
foreach($wat as $res){echo $res;}
?>
So as you can see I get the value of title at the row I'm on and compare it to every value for title in the database, then return only results that match. After that I loop through them and get the value printed.
I have managed to get all the titles out and print them but as soon as i bring $value
into it it breaks. I have checked the value of $value
and it returns the expected result. I just cant figure out what is wrong with my SQL query.
Question
What is wrong with my Query? is there something that stops me using the $row->title
in drupal that I don't know about?