473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

i want to fetch column name which contain -id-, from the database.

Hi All,

I have two table.based on service i need to fetch record from two dates. i.e Tips and category.
category table has column id, name.
Tips table hving id,servicename,services,Date.

service is foreign key of category table. and there is entry in database in -2-, format. I want query for this format. -2-, means 2 is servicename i.e. -HNI-,

Please find my query. do the needful.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.         error_reporting(0);
  3.         $conn=mysql_connect("localhost","root","");
  4. if(!isset($conn)){
  5.     die("connnection failed");
  6.                  }
  7.     mysql_select_db("pinnacle");
  8.     $fdate= $_GET['fdate'];
  9.     $tdate= $_GET['todate'];
  10.  
  11.    $s1= $_GET['service'];
  12.  echo $q="SELECT c1.id, t1.servicename,t1.sentbyname,t1.date,t1.time FROM category AS c1 INNER JOIN tips AS t1 ON  c1.id = t1.services WHERE t1.date BETWEEN '$fdate'  and '$tdate' order by t1.date asc";die;
  13. $rs=mysql_query($q);  
  14.  
  15. when i am removing -HNI-, this symbol from database query works fine.
  16. is there any way to hard code
  17. like
  18. echo $q="SELECT c1.id, c1.name,t1.sentbyname,t1.date,t1.time FROM category AS c1 INNER JOIN tips AS t1 ON "-".c1.id."-," = "-".t1.services."-," WHERE t1.date BETWEEN '$fdate'  and '$tdate' order by t1.date asc";die;
  19.  
  20.  
Thanks
Mar 3 '15 #1
0 1104

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Martin Lucas-Smith | last post by:
Can anyone point me to a regular expression in PHP which could be used to check that a proposed (My)SQL database/table/column name is valid, i.e. shouldn't result in an SQL error when created? ...
2
by: Elmar Grandel | last post by:
Hello, i just updated my mysql database from 4.0.x to 4.1 because i like to have the possibility to create subqueries. My problem with the new release is the following: In my running project i...
2
by: Norman Leung | last post by:
Hi all Would there be a easy way to find the column name(s) which constitute a Primary constraint for a table through navigating the system catalogs. I found that the PK Constraint object in...
10
by: Colleyville Alan | last post by:
I am trying to turn a short and fat (63 columns) table into one that is tall and skinny (7 columns). Basically, I am trying to create a "reverse crosstab" using a looping structure in VBA along...
4
by: JIM.H. | last post by:
Hello, string colVal =((TextBox)e.Item.Cells.Controls).Text; this is how I reach column value in a grid: how can I reach with the column name? some value should be int, some date, how should I...
0
by: ymcj | last post by:
Hi, I'm trying to change the column name - date to Sdate in all the tables in my database. As i have many to change so i tried to search all tables and have it change automatically rather than...
3
by: ymcj | last post by:
Hi, I'm trying to change the column name - date to Sdate in all the tables in my database. As i have many to change so i tried to search all tables and have it change automatically rather than...
5
by: Dylan Parry | last post by:
Hi, At the moment I use code like the following: string myString = this.dataReader.IsDBNull(2) ? null : this.dataReader.GetString(2); With a record from the DB that looks like: ...
1
by: Big Moxy | last post by:
Problem URL - http://projects.zanalysts.com/ariviewer/display.asp?ID=11 I'm using Access as the "database". I get this error in the above URL: ADODB.Fields error '800a0cc1' Item cannot be...
2
by: msrahul | last post by:
Hi EveryOne I have a gridview with sorting enabled. As we all know, when sorting is enabled in a gridview, the column names in the gridview get UNDERLINED permanently. I dont want this. i want the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.