-
Posts
84 -
Joined
-
Last visited
Never
Posts posted by mATOK
-
-
Something like this maybe
SELECT * FROM Request_Group WHERE GroupTypeId='1' (And 1 appears on more than one row) AND WHERE GroupTypeId='6'
???
-
Hi, I'm not sure how to explain what I want in my query but I will do my best
I have a table that contains a key field, Ids, group ids and group names
I have multiple rows for the same id.
I want to find the IDs where data like below is present, i.e. more than 1 row contains a grouptypeid set to 1 and there is at minimum one row that contains a GroupTypeId set to 6
Key Field| ID |groupID |groupType | name
2312316 | 61232 | 2 | 1 | blahblah
2312317 | 61232 | 3 | 1 | lahblahb
2312318 | 61232 | 4 | 1 | ahblahbl
2312319 | 61232 | 6 | 6 | 123456
2312320 | 61232 | 7 | 6 | 234567
-
Thanx Ray... now you see why I titled the post confused?
-
some of them will..... there are multiple rows for each ID... GroupName contains all kinds of data....
it looks like this
RQID | GroupName
1 All Stations
1 London
1 M-F
2 All Stations
2 Paris
2 M-F
So I want to say 1st, show me all the RQ IDs that have say M-F..... The db returns 1 & 2... then I want to say which of the returned RQids (1 & 2) contain London.... it should return 1
This is why I am not trying to do it all in one query
-
**bump**
-
I am trying something like this
$startdate='05/01/2008';
$enddate='05/30/2008';
$SQL1 = "SELECT DISTINCT Request_Group.RequestId
FROM Request_Group
INNER JOIN Request_Date
ON Request_Group.RequestId = Request_Date.RequestId
WHERE
Request_Date.DateFrom >= '$startdate' AND Request_Date.DateTo <= '$enddate'";
$result = mssql_query($SQL1);
while ($requestids = mssql_fetch_array($result)) {
$numofids = count($requestids);
for ($i=0; $i<=$numofids; $i++) {
$SQL2 ="SELECT Request_Group.RequestId
FROM Request_Group
WHERE
Request_Group.GroupName LIKE '%All Stations%' AND RequestId='$numofids[$i]'";
}
-
So in the groupName field you can have All Stations AND London in the same field and row??
Same field, same ID, different row
-
I would like one row returned for each RQ number.. right now I get a bunch... the row #s are inconsequential to me
For instance
SELECT Request_Group.RequestId
FROM Request_Group
INNER JOIN Request_Date
ON Request_Group.RequestId = Request_Date.RequestId
WHERE
Request_Group.GroupName LIKE '%All Stations%' AND
Request_Date.DateFrom >= '2008-05-01' AND Request_Date.DateTo <= '2008-05-31'
gives me the below request ids
53769
53833
53833
53833
53874
53874
53874
53874
53874
53874
54241
54528
now I want to say, which of the above request ids have Request_Group.GroupName LIKE '%London%' .
Remember, each Id could be present on several rows... I just want to keep filtering down until I get a requestId that matches 4 or 5 of my patterns
-
I appreciate the effort but that's not going to get me what I want...
I want the RQ#s that contain specific data in the GroupName field... unfortunately there are multiple rows for each RQ and is why I thought of multiple SQL statments.
I don't know how to loop it using php....
x = all RQs that have 'A' in GroupName
y = all RQs that are found in x that have 'B' in Groupname
z = all RQs that are founf in y that have 'C' in Groupname
-
craygo that SQL does not return anything....
Here is an example of the data I am working with....
RQ# GroupName
120 001 Geography
120 001 Marketa
120 002 Marketb
120 001 Person1
120 001 Stationname
120 002 Stationname
120 003 Stationname
120 004 Stationname
120 M...... 19:00 - 19:30
This is why I figured multiple SQL statments...
-
No that wont work as I don't want to see all stations or M-F, I want to see all stations and M-F... the problem is that the same field contains both but on a different row
-
Hey there... I would like to make a selection from the db and then loop through the results searching for a match and then loop through those results and so on. My problem is that GroupName can contain various things I am looking for but on different rows.
eg
RQID 1 Row 1 GroupName = All Stations
RQID 1 Row 2 GroupName = M-F
RQID 1 Row 3 GroupName = London
So first I want to find all the RQids that fall between certain dates, then I go through those to see if which ones contain All stations, then I want to go through the ones that contain all stations searching for more information....
$SQLrequestID = "SELECT Request_Group.RequestId FROM Request_Group INNER JOIN Request_Date ON Request_Group.RequestId = Request_Date.RequestId WHERE Request_Date.DateFrom >= '$startdate' AND Request_Date.DateTo <= '$enddate'"; $result = mssql_query($SQLrequestID); while ($requestids = mssql_fetch_array($result)) { $SQLrequestID = "SELECT Request_Group.RequestId FROM Request_Group WHERE Request_Group.GroupName LIKE '%All Stations%'"; }
In the end all I really want are the IDs that contain 4 or 5 specific entries in the GroupName field.... can anyone tell me how to go about this?
-
Hey there, wondering if someone could give me a hand writing an SQL query...
I have multiple tables that all have a field RequestId. What I would like to do is pull a list of Request Ids that were submitted on a specific date and then obtain the specifics of those requests from each of the several tables I have.
So far I have been able to get the Request Ids submitted on specific dates with
$startdate='06/03/2008'; $enddate='06/04/2008'; $SQLrequestID = "select RequestId From Request_Run WHERE TimeRunEnd BETWEEN '$startdate' AND '$enddate'"; $result_requestID = mssql_query($SQLrequestID); while ($IDs = mssql_fetch_array($result_requestID)) { echo $IDs['RequestId']."<br />"; }
Now I want to take these Ids and for each id returned grab additional information such as all the info from table Request_Group, Request Measure and so on. And see it sorted by the Id.
How do I make this second part happen?
-
I unzipped and over wrote everything, thanx again wildteen88!
-
Originally I downloaded and installed PHP 5.2.5 installer [19,803Kb] - 15 November 2007 from http://www.php.net/downloads.php
I renamed my self made ext folder to old-ext
I just downloaded PHP 5.2.5 zip package [9,713Kb] - 08 November 2007 from the same place, I extracted the ext and extras folder (another that I did not have) to c:\program files\php. I then copied libmySQL.dll from old-ext to ext.
Stopped and restarted Apache and now my test script
<?php // hostname or ip of server (for local testing, localhost should work) $dbServer='localhost'; // username and password to log onto db server $dbUser='root'; $dbPass='mazlema'; $link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect"); print "Connected successfully<br />"; // close connection mysql_close($link); ?>
displays Connected successfully
Thank you very much everyone for your time and help... is there anything else I should check to be sure that my php install is complete?
-
I have downloaded php_mysql.dll from http://dev.mysql.com/get/Downloads/Connector-PHP-mysqlnd/php_5.2.1-mysqlnd-5.0.1-beta.zip/from/pick and extracted to my c:\program files\php\ext folder.
I stopped and re-started Apache without any change
I still do not have a MySQL are displayed to me when I view phpinfo();
-
I had to create a C:\Program files\php\ext folder myself as it was not present after the install... in it I copied libmySQL.dll
The below is from my php.ini
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;
; If you wish to have an extension loaded automatically, use the following
; syntax:
;
; extension=modulename.extension
;
; For example, on Windows:
;
; extension=php_mysql.dll
;
; ... or under UNIX:
;
; extension=msql.so
;
; Note that it should be the name of the module only; no directory information
; needs to go here. Specify the location of the extension with the
; extension_dir directive above.
extension=php_mysql.dll
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues. The alternate is to use the
; cgi.force_redirect configuration below
doc_root =
; The directory under which PHP opens the script using /~username used only
; if nonempty.
user_dir =
; Directory in which the loadable extensions (modules) reside.
extension_dir ="C:\Program Files\PHP\ext"
php_mysql.dll does not exist on my computer
-
'Earlier I instructed you to added the PHPIniDir directive to the httpd.conf did you follow this step after:
Save the httpd.conf and restart Apache. Rerun phpinfo() and check that the Loaded Configuration File line is set to C:\Program Files\PHP\php.ini'
I did do this and php info returns
Loaded Configuration File C:\Program Files\PHP\php.ini
I do not have a separate MySQL heading when running phpinfo... I have
Configuration
PHP Core
apache2handler
Apache Environment
HTTP Headers Information
bcmath
calendar
com_dotnet
ctype
date
dom
filter
ftp
hash
iconv
json
libxml
odbc
pcre
Reflection
session
SimpleXML
SPL
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
zlib
Additional Modules
Environment
PHP Variables
PHP License
-
under which section?
mysql is in the paths...
-
// hostname or ip of server (for local testing, localhost should work)
$dbServer='localhost';
// username and password to log onto db server
$dbUser='root';
$dbPass='mazlema';
$link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect"); ---- Line 9 ---
print "Connected successfully<br />";
// close connection
mysql_close($link);
-
Thanks PFMaBiSmAd!
I changed display_errors to On and now I get the below...
Fatal error: Call to undefined function mysql_connect() in C:\WEB\mysql.php on line 9
-
Thank you, I made the change but still can't connect to MySQL??
I am trying:
<?php // hostname or ip of server (for local testing, localhost should work) $dbServer='localhost'; // username and password to log onto db server $dbUser='root'; $dbPass='mazlema'; $link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect"); print "Connected successfully<br />"; // close connection mysql_close($link); ?>
and I get a blank page... no code at all if I do a view source
-
Thanx for your reply!
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File (none)
php.ini is located in C:\Program Files\PHP
-
so I'm not the only one who's stumped
How to...
in Microsoft SQL - MSSQL
Posted
select distinct requestid
from request_group
where grouptypeid = 6
and requestid in
(select requestid
from request_group
where grouptypeid = 1
group by requestid, grouptypeid
having count(*) > 1)