Answer the question
In order to leave comments, you need to log in
MSSQL query in PHP?
Good afternoon! For some, the question will seem silly, but I hope it will be answered ...
So, there is a MSSQL database. Through Microsoft SQL Server Management Studio I execute the query:
select count(DISTINCT stb.mac)
from [tve_34_sp1].[dbo].[SET_TOP_BOX] stb
inner join [tve_34_sp1].[dbo].[PARTY_ROLE] pr on stb.owner = pr.id
inner join [tve_34_sp1].[dbo].[PARTY] nm on pr.party = nm.id
inner join [tve_34_sp1].[dbo].[CUSTOMER] cs on stb.owner = cs.id
inner join [tve_34_sp1].[dbo].[SERVICE] ss on stb.owner = ss.customer
inner join [tve_34_sp1].[dbo].[SERVICE_SPECIFICATION] sp on ss.srv_spec = sp.id
where pr.name like 'Q%'
and sp.name like 'blabla';
<?php
$link = mssql_connect('1.2.3.4', 'sa', 'password');
mssql_select_db('tve_34_sp1', $link);
$sql = "select count(DISTINCT stb.mac)
from [tve_34_sp1].[dbo].[SET_TOP_BOX] stb
inner join [tve_34_sp1].[dbo].[PARTY_ROLE] pr on stb.owner = pr.id
inner join [tve_34_sp1].[dbo].[PARTY] nm on pr.party = nm.id
inner join [tve_34_sp1].[dbo].[CUSTOMER] cs on stb.owner = cs.id
inner join [tve_34_sp1].[dbo].[SERVICE] ss on stb.owner = ss.customer
inner join [tve_34_sp1].[dbo].[SERVICE_SPECIFICATION] sp on ss.srv_spec = sp.id
where pr.name like 'Q%'
and sp.name like 'blabla'";
$sql = mssql_query($sql);
while($obResults = mssql_fetch_row($sql))
{
echo $obResults[0];
}
mssql_close($link);
?>
Answer the question
In order to leave comments, you need to log in
As a hypothesis: it is possible that the problem is in Collation. A colleague came across and solved it, so I can’t suggest the way to check / solve on the fly.
It looks like join requests are not being handled correctly...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question