Jump to content

nadeemshafi9

Members
  • Posts

    1,245
  • Joined

  • Last visited

Posts posted by nadeemshafi9

  1. That's not a subquery, that's a derived table... should be supported.

     

    no it fails on the acua

    That's not a subquery, that's a derived table... should be supported.

     

    im prety sure

     

    USING ( section_id )

    INNER JOIN (

     

    SELECT d.data_id

    FROM rds_table AS r

    INNER JOIN data_table AS d

    USING ( data_id )

    INNER JOIN _data_rds_link AS _drl

    USING ( rds_id )

    WHERE d.data_status = 'current'

    AND r.rds_id =1

    ) AS derived

    USING ( data_id )

     

    this part is a sub query even thogh the table is a dervied table ????, it inner joins to a subquery

  2. hi guys

     

    i am doing all sorts of ajax updates on the page and updating records, prob is when records are updated views change and record id changes, but the url does not unfortunatly it contains the old records id and on reload eg if the user hapens to press refresh the page will revert to an old record, this causes chaos and i need to alter the url when records are updated (my records on update are archived so a new record is made with new id) his is why i need to know if theres a way of changuing the url without redirecting the user or refreshing.

     

    Thanks

  3. I just got Software engineering a practitioners approach 6th ed by pressman it has some good working web engineering practices, before this i had software engineering 8 the student bible one i forgot what its called. The proper software engineering 8th edition is proper specific as in it goes in to the foundational details, the practitioners approach is more topological and helps working people.

  4. OK this is the same error i had with the normal specific join above it basicaly rejects the SELECT in the sub query if i use str8 out numbers eg  in (1,2,3) it works but if i do a IN (SELECT) it breaks. Il try it on mysql 5 on the live server

     

    SELECT d. *

    FROM data_table AS d

    INNER JOIN _data_section_link AS _dsl

    USING ( data_id )

    INNER JOIN section_table AS s

    USING ( section_id )

    INNER JOIN (

     

    SELECT d.data_id

    FROM rds_table AS r

    INNER JOIN data_table AS d

    USING ( data_id )

    INNER JOIN _data_rds_link AS _drl

    USING ( rds_id )

    WHERE d.data_status = 'current'

    AND r.rds_id =1

    ) AS derived

    USING ( data_id )

    WHERE s.section_id =1

    LIMIT 0 , 30

     

    MySQL said: Documentation

    #1064 - You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT d.data_id FROM rds_table AS r INNER JOIN data_table AS d

  5. Which version of mysql are you using -- checking for subquery support here.

     

    Either way, it would be easier to re-write this using a dervied table.

     

    i re wrote it using php cos its just not working with a subquery, its mysql 4.0.21, well i got it working with php subquery but i need teh proper thing working heres the working code.

     

    <?php
    function get_section_data($section_id){
    
    	// the sub query is not working so i have to do it manualy
    
    	/*$sql = "SELECT d.* FROM rds_table r, data_table d, _data_rds_link _drl ".
    	"WHERE ".
    	"d.data_id = _drl.data_id AND ".
    	"r.rds_id = _drl.rds_id AND ".
    	"d.data_status = 'current' AND ".
    	"d.data_id = Any (".
    		"SELECT d.data_id FROM data_table d, section_table s, _data_section_link _dsl ".
    		"WHERE ".
    		"d.data_id = _dsl.data_id AND ".
    		"s.section_id = _dsl.section_id AND ".
    		"s.section_id = ".$section_id.
    	") AND ".
    	"r.rds_id = ".$this->rds_id;*/
    
    
    	$sql = "SELECT d.* FROM data_table d, section_table s, _data_section_link _dsl ".
    	"WHERE ".
    	"d.data_id = _dsl.data_id AND ".
    	"s.section_id = _dsl.section_id AND ".
    	"s.section_id = ".$section_id;
    	$result = mysql_query($sql);
    	if($GLOBALS['sys_debug']) echo $sql." ".mysql_error();
    
    	while($data = mysql_fetch_array($result)){
    		$condition .= ",".$data['data_id'];
    	}
    
    	$sql = "SELECT d.* FROM rds_table r, data_table d, _data_rds_link _drl ".
    	"WHERE ".
    	"d.data_id = _drl.data_id AND ".
    	"r.rds_id = _drl.rds_id AND ".
    	"d.data_status = 'current' AND ".
    	"d.data_id IN (0".$condition.") AND ".
    	"r.rds_id = ".$this->rds_id;
    	$result = mysql_query($sql);
    
    	if($GLOBALS['sys_debug']) echo $sql." ".mysql_error();
    	return $result;
    }
    ?>
    

  6. this is what i whant but its not working

     

    /*$sql = "SELECT d.* FROM rds_table r, data_table d, _data_rds_link _drl ".

    "WHERE ".

    "d.data_id = _drl.data_id AND ".

    "r.rds_id = _drl.rds_id AND ".

    "d.data_status = 'current' AND ".

    "d.data_id IN (".

    "SELECT d.data_id FROM data_table d, section_table s, _data_section_link _dsl ".

    "WHERE ".

    "d.data_id = _dsl.data_id AND ".

    "s.section_id = _dsl.section_id AND ".

    "s.section_id = ".$section_id.

    ") AND ".

    "r.rds_id = ".$this->rds_id;*/

     

     

    so im having to do it manualy

     

    $sql = "SELECT d.* FROM data_table d, section_table s, _data_section_link _dsl ".

    "WHERE ".

    "d.data_id = _dsl.data_id AND ".

    "s.section_id = _dsl.section_id AND ".

    "s.section_id = ".$section_id;

    $result = mysql_query($sql);

    if($GLOBALS['sys_debug']) echo $sql." ".mysql_error();

     

    while($data = mysql_fetch_array($result)){

    $condition .= ",".$data['data_id'];

    }

     

    $sql = "SELECT d.* FROM rds_table r, data_table d, _data_rds_link _drl ".

    "WHERE ".

    "d.data_id = _drl.data_id AND ".

    "r.rds_id = _drl.rds_id AND ".

    "d.data_status = 'current' AND ".

    "d.data_id IN (0".$condition.") AND ".

    "r.rds_id = ".$this->rds_id;

    $result = mysql_query($sql);

     

    if($GLOBALS['sys_debug']) echo $sql." ".mysql_error();

    return $result;

  7. RELATIONS - the data is related to the sections and and also related to teh rds, each section is displayed in every rds the data for that section is detrmined by selecting all data related to that section wich will reurn data that is related to other rds's but then we need to filter data for that section by saying look we are in this rds so show us data for this section thats related to this rds, ???? lol

     

    data is related to RDS's

     

    RDS's are made up of sections

     

    data is related to sections and further filtered by there relation to RDS's

     

    first i get all the data for the section wich will get me data related to all rds's

     

    SELECT d.* FROM data_table d, section_table s, _data_section_link _dsl WHERE d.data_id = _dsl.data_id AND s.section_id = _dsl.section_id AND s.section_id = 1

     

     

    then i whant to filter this data in this section by the RDS (room data sheet) i am currently in

     

    AND d.data_id IN (SELECT d.data_id FROM rds_table r, data_table d, _data_rds_link _drl WHERE d.data_id = _drl.data_id AND r.rds_id = _drl.rds_id AND d.data_status = 'current' AND r.rds_id = 1)

     

     

    data is archived on update aswell thats why i have current so dont worry about that

  8. here is the echo

     

    SELECT d.* FROM data_table d, section_table s, _data_section_link _dsl WHERE d.data_id = _dsl.data_id AND s.section_id = _dsl.section_id AND s.section_id = 1 AND d.data_id IN (SELECT d.data_id FROM rds_table r, data_table d, _data_rds_link _drl WHERE d.data_id = _drl.data_id AND r.rds_id = _drl.rds_id AND d.data_status = 'current' AND r.rds_id = 1)

     

     

    here is another one from the list its meant to produce

     

    SELECT d.* FROM data_table d, section_table s, _data_section_link _dsl WHERE d.data_id = _dsl.data_id AND s.section_id = _dsl.section_id AND s.section_id = 2 AND d.data_id IN (SELECT d.data_id FROM rds_table r, data_table d, _data_rds_link _drl WHERE d.data_id = _drl.data_id AND r.rds_id = _drl.rds_id AND d.data_status = 'current' AND r.rds_id = 1)

  9. iv tested both queries individualy they work

     

    function get_section_data($section_id){

    $sql = "SELECT d.* FROM data_table d, section_table s, _data_section_link _dsl ".

    "WHERE ".

    "d.data_id = _dsl.data_id AND ".

    "s.section_id = _dsl.section_id AND ".

    "s.section_id = ".$section_id." AND ".

    "d.data_id IN (".

    "SELECT d.data_id FROM rds_table r, data_table d, _data_rds_link _drl ".

    "WHERE ".

    "d.data_id = _drl.data_id AND ".

    "r.rds_id = _drl.rds_id AND ".

    "d.data_status = 'current' AND ".

    "r.rds_id = ".$this->rds_id.

    ")";

     

    $result = mysql_query($sql);

    echo $sql." ".mysql_error();

    return $result;

    }

     

     

    still no luck like thsi thiogh

  10. here are teh tables

     

    
    CREATE TABLE `data_table` (
      `data_id` int(11) NOT NULL auto_increment,
      `data_lang` varchar(255) default '0',
      `data_project` int(11) default '0',
      `data_createdate` timestamp(14) NOT NULL,
      `data_createby` int(11) default '0',
      `data_moddate` timestamp(14) NOT NULL default '00000000000000',
      `data_modby` int(11) default '0',
      `data_status` enum('current','pending','archived') default 'current',
      `data_title` varchar(255) default NULL,
      `data_text` text,
      PRIMARY KEY  (`data_id`)
    ) TYPE=MyISAM AUTO_INCREMENT=4 ;
    
    CREATE TABLE `rds_table` (
      `rds_id` int(11) NOT NULL auto_increment,
      `rds_lang` varchar(255) default NULL,
      `rds_project` int(11) default NULL,
      `rds_zone` int(11) default NULL,
      `rds_createdate` int(11) default NULL,
      `rds_createby` varchar(255) default NULL,
      `rds_moddate` timestamp(14) NOT NULL,
      `rds_modby` int(11) default NULL,
      `rds_status` enum('current','pending','archived') default NULL,
      `rds_title` varchar(255) default NULL,
      `rds_pri_rel` int(11) default NULL,
      `rds_sec_rel` int(11) default NULL,
      PRIMARY KEY  (`rds_id`)
    ) TYPE=MyISAM AUTO_INCREMENT=17 ;
    
    CREATE TABLE `section_table` (
      `section_id` int(11) NOT NULL auto_increment,
      `section_lang` int(11) default NULL,
      `section_createdate` timestamp(14) NOT NULL,
      `section_createby` int(11) default NULL,
      `section_moddate` timestamp(14) NOT NULL default '00000000000000',
      `section_modby` int(11) default NULL,
      `section_status` enum('current','pending','archived') default NULL,
      `section_title` varchar(255) default NULL,
      `section_text` text,
      PRIMARY KEY  (`section_id`)
    ) TYPE=MyISAM AUTO_INCREMENT=3 ;
    
    CREATE TABLE `_data_section_link` (
      `_id` int(11) NOT NULL auto_increment,
      `section_id` int(11) NOT NULL default '0',
      `data_id` int(11) NOT NULL default '0',
      PRIMARY KEY  (`_id`)
    ) TYPE=MyISAM AUTO_INCREMENT=3 ;
    
    CREATE TABLE `_rds_section_link` (
      `_id` int(11) NOT NULL auto_increment,
      `section_id` int(11) NOT NULL default '0',
      `rds_id` int(11) NOT NULL default '0',
      PRIMARY KEY  (`_id`)
    ) TYPE=MyISAM AUTO_INCREMENT=10 ;
    

  11. hi guys i have 2 link tables for M:N relationships i need to select the data that is related to an RDS and the data has to be part of the SECTION in that RDS

    <?php
    function get_section_data($section_id){
    
    	$sql = "SELECT d.* FROM rds_table r, data_table d, _data_rds_link _drl ".
    	"WHERE ".
    
    	"d.data_id = _drl.data_id AND ".
    	"r.rds_id = _drl.rds_id AND ".
    
    	"d.data_status = 'current' AND ".
    	"r.rds_id = ".$this->rds_id." AND ".
    
    	"d.data_id =  ( ".
    		"SELECT d.data_id FROM data_table d, section_table s, _data_section_link _dsl ".
    		"WHERE ".
    		"d.data_id = _dsl.data_id AND ".
    		"s.section_id = _dsl.section_id AND ".
    		"s.section_id = ".$section_id." ".
    	");";
    
    	$result = mysql_query($sql);
    	if($GLOBALS['sys_debug'])  echo $sql." ".mysql_error();
    	return $result;
    }
    
    ?>
    

     

    i got good marks 100% for my SQL test but that was ages ago now i cant get my head around it

     

    thanks for nay help

  12. theres a recession in the uk, they say it bites anyone who come snear it i never seen it thogh so i dont belive in it.

     

     

    Do you believe in air?

     

     

    You were kidding, right?  The technical term of a recession has definitely been met, although some people feel it less than others.

     

    i live with my parents i dont pay rent so i guess ur right

  13. when u go to school the teachers can do anything to u, just know ur lucky in eastern countries they are allowed to beat u with a cane.

     

    Actually in eastern countries, It is the school teachers, managers ... which has the full right and respect. They can do almost anything they want. If they are harsh to you, Your option is to change your school. Very rare happens parents sue some teacher at school. There's this image in people's mind that "student is always guilty". 

    I remember when I was at school, There was this guy that had some awsome parents, always when he did something wrong at school, and school call for his parents, his parents always used to say the school teachers "You sure did something to my son, he wouldn't do something wrong if you won't annoy him" . And the boy was really guilty and rude most of the times, but this kind of support from his parents had made him so confident.  I was always jealous of his parents. my parents replies always were like "Thanks for calling us, we will talk to him" , which most of the time I hadn't do anything serious at all.  ^^

     

    my dad is old school pakistani, when teachers called him he would say, 'i see when he get home i show him'

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.