I'm trying to find where is placed the shipping methos with MySQl in WordPress but I can only find something when order is completed.
If I search in to a completed order:
SELECT * FROM `wp_woocommerce_order_itemmeta` WHERE `order_item_id` = 123456
I can get de following information
This is good, but if order is not closed this information is not saved.
Any idea to get this information before order is completed?
Thanks,
Related
I have setup my own server for a multiplayer pvp game 3 days ago, I am using a plugin that allows players to earn points in the server and stores everything in a MySQL database which I have full access to.
Yesterday I started working on a website for my server and I came up with an idea to make the points system more interesting for the players, I want to make a table on my website that extracts the top 10 players from my database and puts them into a HTML table.
I tried searching for this online, but found answers that only allowed me to extract all players or sort them by name etc, I just need the top 10 with the highest value in the column "points".
The database table name is "ranks" the column with the names is "lastDisplayName" and the column with points is called "points"
I would really appreciate it if someone could help me find a way to put this in a table that sais Rank, Name and points.
Sadly I can't upload the picture to show what my table would look like.
Try the query below
SELECT DISTINCT lastDisplayName FROM ranks ORDER BY `points` DESC LIMIT 10;
I must extract a report from MySQL of how many times a client visited our office. The rule is to count a visit only if it has passed 24 from the last visitation.
If a client visits the office two times in one day, this should count as 1 (for the report).
However, the visit will be registered everytime in the database and I cannot change the database or create new tables. I must work with what I have.
Follows a SQL Fiddle of my scenario:
The outuput should be two visits were done in 29/aug, one visit done in 03/sept.
http://sqlfiddle.com/#!2/fc7f5/2/0
Could someone please put me in the right direction to archive this? I googled as much as I could and did not find the right answer.
Thank you very much in advance for your time and help.
Looks like you need to use GROUP BY:
select date(visit_date), count(*)
from visits
where client_id =1
group by date(visit_date)
SQL Fiddle Demo
Notes:
You may or may not need to convert visit_date to a date in the group by -- depends on whether it stores the time of the visit or just the date.
Also, you may need to use count distinct(client_id) since you mention not counting the same client twice in the same day. A little unclear from your question.
If you use select visit_date,count(*) from visits where client_id=1 group by visit_date You'll see that it now reports 2 visits for 29/aug and one for 03/sept.
Count the number of rows returned to find out how many visits the patient has had.
I've been duplicating my data as as noted by the asterisk * below in Snippet 1. This duplication allowed me to run a simple query as such:
"SELECT * FROM tweets ORDER BY time DESC LIMIT 7",
This populates 7 tweets as a default setting.
However, I want to eliminate these redundant columns. To do this I need to pull the other fields from the credentials table.
How would I run a complex query like this? Is this feasible? Is it a good idea?
Snippet 1
Table 1 - tweets (7)
id
h_token
h_file *remove and pull from credentials
picture *remove and pull from credentials
name *remove and pull from credentials
tweet
time
Table 2 - credentials (12)
id
name
email
h_pass
picture
privacy
h_token
h_file
special
page
pane
remember
Each tweet has an h_token associated with it that will be used to add relational data (h_file, name, and picture)
You need to use a join operation, like so:
SELECT tweets.*, credentials.h_file, credentials.picture, credentials.name
FROM tweets JOIN credentials ON tweets.h_token=credentials.h_token
ORDER BY time DESC LIMIT 7;
This is basically your original query, but adding three columns from the credentials table whenever the h_token from the credential and tweets table match up......
So I am working on an Invoicing Report in SSRS 2008. The database contains 4 relevant tables:
- Work Order
- Labor
- Materials
- Services (Subcontractors)
Obviously the work order table contains all the relevant information about the overall work order (we display things such as location, priority, etc). For this invoice report, I need to display the work order details up at the top, then show the labor, materials, and services used on the work order (with totals for each), then show a complete total for the entire cost of the work order.
My issue is this: I can do a dataset that works with Work Order + any ONE of the child tables, however I cannot figure out how to do all 3! I can't simply do a parameter for WONUM with 3 (or 4) tables on it, because this report will have MANY work orders (one per page) on it. When I use a dataset with the Work Order table and one child table, I group by WONUM then do a page break between each instance.
Any ideas for how to handle it? Most answers I came across say make one gigantic "union all" dataset and then group it after that, or use subreports for each child table. However, we will be exporting this report to Excel, and I've been told that subreports do not render properly when exported.
Any and all help is greatly appreciated! Thanks!
EDIT:
Below are the 4 queries I'd LIKE to use:
This retrieves all the work orders that need to be billed:
SELECT wonum, description, location FROM workorder WHERE billable=1 AND status='COMP'
This retrieves the labor for a work order (specified by #wonum)
SELECT regularhrs, laborrate, totalcost FROM labor WHERE refwo=#wonum
This retrieves the materials for a work order (specified by #wonum)
SELECT description, quantity, unitcost, totalcost FROM material WHERE refwo=#wonum
This retrieves the services (subcontractor hours) for a work order (specified by #wonum)
SELECT description, hours, laborrate, totalcost FROM service WHERE refwo=#wonum
So as I stated in the original post, my first query retrieves all the work orders that need to be billed, then for each work order (one per page), I need to retrieve the labor, materials, and services and display it in 3 tables below the work order details, then put an overall total cost on the work order invoice (at the end of each work order, not the end of all work orders)
I can get a screenshot of my current report if that would help also. Just let me know in comments!
Your query should look something like this
SELECT WO.wonum, WO.description as WorkorderDescription, WO.location, L.regularhrs, L.laborrate, L.totalcost,
M.description as MaterialDescription, M.quantity, M.unitcost, M.totalcost as MaterialCost,
S.description as ServiceDescription, S.hours, S.laborrate, S.totalcost as ServiceCost
FROM workorder AS WO
INNER JOIN labor AS L on L.refwo = WO.wonum
INNER JOIN material AS M on M.refwo = WO.wonum
INNER JOIN service AS S on S.refwo = WO.wonum
WHERE billable = 1 AND STATUS = 'COMP'
This will efficiently gather the information you need into one dataset. You will need to use the grouping features to setup the table in SSRS. You may have to do some additional research if you get stuck on getting the table layout right.
I am currently building a mobile(Android) app that is a search engine for products. The products information, is currently stored in a WordPress eCommerce store(WooCommerce). I have added 5 sample products to this store for testing purposes.
I currently have the search function working inside the app. The MySQL query used for this search is as follows:
SELECT a.*, b.guid AS img_url
FROM wp_posts AS a
LEFT JOIN wp_posts AS b ON a.ID = b.post_parent
WHERE a.post_type='product'
AND a.post_title LIKE '%$search%'
Now, when I search for something like "sample", I get my search results with all of the products that contain the word sample in it's title.
However, if one of those products has more than one image attached to it. I get results for as many images that are attached to the product.(see screenshot below)
Screenshot: http://cl.ly/M7Ap
If anyone could help me with this, so that I don't get the multiple results for the one post. It would be greatly appreciated.
If you don't care about which result, but just want one per post, can you not just use GROUP BY?