mysql

Can this Mysql query be amended to display invoice only once for the same idinvoice

The query below SELECT <output name="c.name" title="Name" />, <output name="c.reference" title="Reference No." />, <output name="i.idinvoice" title="Invoice ID" />, <output replace="(SUM(v.quantity * s.charges))/COUNT(i.idinvoice)" />As Invoice <output replace="p.amount" />AS Amount, <output replace="p.idpayment" title="Payment ID" />, ...

Searching MySQL fields with similar fieldnames

Hi. New to mysql and php, so forgive any obvious stupidity, please! One of mysql tables has category fields, indexed from a table of categories. Each of the categories is named category_1, category_2, category_3, etc. I'm assuming that can't I use a wildcard to search these categories, like: 'SELECT * FROM products_table WHERE cat...

if clause in mysql

i want a simple example of if clause in mysql. i don't want to consider else case,only if clause ...

Formatting PHP time() from mysql table

I'm creating comments stored in a MySQL database. I'm logging the php time function time() as the comment is posted. That way it's displaying a message such as... "comment... posted 4 seconds ago" and if I refresh the page 2 minutes later it'd display "comment... posted 2 minutes ago" Here's how I am entering time() into the database ...

What's wrong with this MySQL query?

Sorry because this is a noob question. I'm new with MySQL: I wrote a query like this: SELECT u.userid, u.alias, g.company_name, v.endtime - v.begintime AS duration, u.status, u.service_starttime, u.service_expiretime, v.begintime, u.email FROM company_users c, company_groups g INNER JOIN user_info u INNER JOIN vfon_l...

Asterisk billing system with PHP

Hi, I am trying to develop billing system for asterisk but i dont know howto start.Is there any suggestion for this?I have looked at free billing systems for asterix but their systems are very complicated and i asked here. Thanks for advance... ...

JOIN three tables

I am trying to retrieve two sets of information (the red and blue portions of the diagram in the one query. I thought I could do it using the sql as stated below but it does not return me anything when TableC has no records. If TableC has no records, I would still want this query to return me the results as indicated by the BLUE area. ...

CodeIgniter MySQL Query not returning any data, even though there definitely is data to be returned!

Hi there! I have a CI Model set up with this function and ActiveRecord: function get_open_competitions() { $this->db->select('*, TO_DAYS(closingdate) - TO_DAYS(CURDATE()) AS days') ->from('challenges') ->where('closingdate >','CURDATE()') ->order...

Any optimization Idea for this SQL (mySQL)?

I know the best way would be not to have any sql inside other sql, specially a complicated one, and would be better to use the analysis after the query, but because the way the system is build I would preffer to do it only on one query Here is the query in question ("is a really cool query") SELECT DISTINCT o.orders_id, o.faltantes...

MySQL/PHP: Find previous / next row

Hi I'm making a forum for skills. I want to print a previous and/or next link on the thread page. So if theres a thread with a larger and/or lesser number than current, print it in lionk. And also i wanna limited only threads from the same forum as the thread im viewing is located in. Basically likes this forum: http://forum.tibia.co...

mysql Illegal mix of collations (latin1_swedish_ci,IMPLICIT)

When I execute this query SELECT * FROM login_table WHERE username = 'sam' AND pass = AES_ENCRYPT('passabc', 'mystring') I keep on getting this error. #1267 - Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' Thanks in advance for any help ...

Track Page Views using PHP

I'm looking for a way to track the number of visits to a page, without counting duplicates (like someone hitting refresh several times) and I'd like to figure out the best way to do it without keeping track of every single IP address to view the page. Perhaps a cookie? Any other suggestions? ...

Database design for items that have restricted shipping regions

I am designing the database for a shopping cart and I am having trouble deciding which way to approach this problem. There are three tiers that can items can be restricted to: 1) Local Delivery Only 2) Shipping Available a) Country b) State c) Region I am thinking to go with a structure like this: product_shipping_res...

Unknown column 'building_requirements_count' in 'field list'

I'm make a little game in php with mysql. Now I have a problem with one of the sql query's I created. The idea is that the query checks if the user has enough materials. I have a query that if I use it like this it works: SELECT ( SELECT COUNT(*) FROM building_requirements WHERE building_id = '1' ) as building_requirements_count...

Simple php/mysql problem

I have a "Jump To"-select box on my forum. I want the forum that the thread I'm currently viewing to be SELECTED in the selectmenu. I tried this: $threadinfo = mysql_query("SELECT * FROM threads WHERE id = $threadid"); $thread = mysql_fetch_assoc($threadinfo); $forums = mysql_query("SELECT * FROM forums ORDER BY name ASC"); while($f...

function to return regular expression matches in mysql like preg_match return array in php

Hi, I've table with data like ticketid | comments ---------------------- 1234 | > > Ticket ID:TT19027 > > Ticket Title:report debug > > 4567 |> > Ticket ID:TT19028 > > Ticket Title:report debug > > I'm looking for a function or query that will return ticketid | ticket_no_part_of_comments 1234 | TT19027 4567 ...

[Approach] Multilang catalog(with custom fields) DB structure design

Hi, Soon I'll be working on catalog(php+mysql) that will have multilang content support. And now I'm considering the best approach to design the database structure. At the moment I see 3 ways for multilang handling: 1) Having separate tables for each language specific data, i.e. schematicly it'll look like this: There will be one tab...

PHPMyAdmin cannot connect to MySQL

I installed the lampp sever on my local in linux OS, but its giving error while opening phpmyadmin. #2002 - The server is not responding (or the local MySQL server's socket is not correctly configured) ...

Writing PHP into Javascript or Javascript Into PHP

i have this code var myChart = new FusionCharts("../themes/clean/charts/hbullet.swf", "myChartId", "400", "75", "0", "0"); myChart.setDataXML("<chart lowerLimit='0' upperLimit='100' caption='Revenue' subcaption='US $ (1,000s)' numberPrefix='$' numberSuffix='K' showValue='1'><colorRange><color minValue='0' maxValue='50' color='A6A...

how returns the boolean value from function in mysql?

i have column a ,column b in emp table. i like to retrieve values from that column find the difference between them. if i get 0 as difference i will return true else i will return false using functions.i am new to database so only i don't know how to do this.i like to know how to store the retrieved values from table to variable. i dont ...