Silverlight and linq/ria select how to, do the following - silverlight

query_TMEditSheet = _
From tm In Context_DomainService1TMTM.GetTMTMSQuery()
From ts In Context_DomainService1TMTM.GetGECODsQuery()
Where tm.tmsDate = MainPage.TimeSheetDateSelect_selectdate.Date
Where tm.tmsUserID = ts.codType
Defination method select many is not accessible in this context
want to select tmtms records whose userid is present in the codType(of the gecod table)
please guide

What I think you want to do is:
from tm in Context_DomainService1TMTM.GetTMTMSQuery()
join ts in Context_DomainService1TMTM.GetGECODsQuery() on tm.tmsUserID equals ts.codType
where tm.tmsDate = MainPage.TimeSheetDateSelect_selectdate.Date

Related

Updating one table's column in SQL Server from another

I have a table of measurements from weather stations, with station names (in Hebrew):
I also have created a table of those weather stations with their latitudes and longitudes:
I've written a query that should update the first table with the lat/longs from the second, but it's not working:
update t1
set t1.MeasurementLat = t2.Latitude,
t1.MeasurementLong = t2.Longitude
from [dbo].[Measurements] as t1
inner join [dbo].[StationCoords] as t2 on t1.StationName like t2.Station
I think there is a problem with the way the station name is being read, and perhaps something to do with encoding, because this query brings back an empty result, too:
SELECT TOP (5) *
FROM [dbo].[Measurements]
WHERE [StationName] = 'אריאל מכללה';
Any ideas?
Your example names are not the same. Perhaps this will work:
update m
set MeasurementLat = sc.Latitude,
MeasurementLong = sc.Longitude
from dbo.[Measurements] m join
dbo.[StationCoords] sc
on m.StationName like sc.Station + '%';

multiple part identifier couldn't be bound

i am trying to make a query that finds the item number and change the shelf number based on the id in another table but i getting a
multiple part identifier couldn't be bound
on SET and WHERE how do i fix that or are there another way around this
use [ISTABLocalDB]
SELECT
ps.[ShelfNumber], P.[ItemNumber]
FROM
[file].[Item] P
inner join [file].[ItemPart] PS on P.[ID] = PS.[ID]
UPDATE [file].[ItemPart]
SET ps.[ShelfNumber]='Test'
WHERE P.[ItemNumber] LIKE 'N84754'
UPDATE PS
SET [ShelfNumber] = 'Test'
FROM [file].[ItemPart] PS
JOIN [file].[Item] P ON P.[id] = PS.[id]
WHERE P.[ItemNumber] = 'N84754'

Update Weight in magento 1.9 on mass

I am trying to create a MySQL statement that I can put in a php script to update the weight on a few thousand products in magento 1.9.
This is the statement I currently have:
UPDATE dp_catalog_product_entity_decimal AS ped JOIN dp_eav_attribute AS ea ON ea.entity_type_id = 10 AND ea.attribute_code = 'weight' AND ped.attribute_id = ea.attribute_id SET ped.value = 8 WHERE ped.entity_id = P1000X3;
It was partially taken from another post so I am not sure if it will work at all but I currently have the error "#1054 - Unknown column 'P1000X3' in 'where clause'"
I am not that great with sql joins and I dont really know the magento databse at all so any help to get this statement to work is much apreciated.
Thanks.
Matt
The correct SQL to update the weight of a product with a specific SKU in Magento is this (replace YOUR-MAGENTO-SKU with the sku of the item you want to update, and the 8 with the weight value).
UPDATE catalog_product_entity_decimal AS cped
JOIN eav_attribute AS ea ON ea.entity_type_id = (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = 'catalog_product')
LEFT JOIN catalog_product_entity AS cpe ON cpe.entity_id = cped.entity_id
AND ea.attribute_code = 'weight'
AND cped.attribute_id = ea.attribute_id
SET cped.value = 8
WHERE cpe.sku = 'YOUR-MAGENTO-SKU';
In your case, you have the table prefix dp_, and the product sku P1000X3, so the correct SQL for you would be:
UPDATE dp_catalog_product_entity_decimal AS cped
JOIN dp_eav_attribute AS ea ON ea.entity_type_id = (SELECT entity_type_id FROM dp_eav_entity_type WHERE entity_type_code = 'catalog_product')
LEFT JOIN dp_catalog_product_entity AS cpe ON cpe.entity_id = cped.entity_id
AND ea.attribute_code = 'weight'
AND cped.attribute_id = ea.attribute_id
SET cped.value = 8
WHERE cpe.sku = 'P1000X3';
After running this, be sure to reindex your Magento Indexes.
Do your Magento tables have the prefix dp_? Make sure of this.
Also on this part:
WHERE ped.entity_id = P1000X3;
ped.entity_id will be an integer value (number).
I'm not sure where you got P1000X3, but using that won't work (it's a string value). Even so, strings should be wrapped with a single quotes ', like this:
'P1000X3';

Add weight parameter in custom module

I created a content type and it's have many nodes. And write custom module for show on frontpage.
My nodes order:
$themeurl = '/drupal/'.path_to_theme().'/images';
$sql = "SELECT * FROM `node`
LEFT JOIN `field_data_field_anasayfa_catwalk` ON `field_data_field_anasayfa_catwalk`.`entity_id` = `node`.`nid`
WHERE type = 'designers_albums'
AND `node`.`status` = 1
AND `node`.`language` = '".$language->language."'
AND `field_data_field_anasayfa_catwalk`.`field_anasayfa_catwalk_value` = 1
ORDER BY `node`.`created` ASC";
But now, installed Weight module and want sort by weight. How can i change this option? Thank you.
Entities(nodes) weights are stored in weight_weights database table.
You can try that query
$sql = "SELECT * FROM `node`
LEFT JOIN `field_data_field_anasayfa_catwalk` ON `field_data_field_anasayfa_catwalk`.`entity_id` = `node`.`nid`
LEFT JOIN `weight_weights` AS w ON w.entity_id=`node`.`nid`
WHERE type = 'designers_albums'
AND `node`.`status` = 1
AND `node`.`language` = '".$language->language."'
AND `field_data_field_anasayfa_catwalk`.`field_anasayfa_catwalk_value` = 1
ORDER BY w.weight, `node`.`created` ASC";
Btw, in future you should consider learning Drupal database abstraction layer or EntityFieldQuery.

What is the problem with the logic in my UPDATE statement?

I would appreciate some help with an UPDATE statement.
I want to update tblOrderHead with the content from tblCustomer where the intDocumentNo corresponds to the parameter #intDocumentNo. But when I run the my statement, the order table is only updated with the content from the first row of the customer table.
What is the problem with my logic?
I use Microsoft SQL Server.
Thanks,
Stefan
UPDATE dbo.tblOrderHead
SET dbo.tblOrderHead.intCustomerNo = #intCustomerNo ,
dbo.tblOrderHead.intPaymentCode = dbo.tblCustomer.intPaymentCode,
dbo.tblOrderHead.txtDeliveryCode = dbo.tblCustomer.txtDeliveryCode,
dbo.tblOrderHead.txtRegionCode = dbo.tblCustomer.txtRegionCode,
dbo.tblOrderHead.txtCurrencyCode = dbo.tblCustomer.txtCurrencyCode,
dbo.tblOrderHead.txtLanguageCode = dbo.tblCustomer.txtLanguageCode
FROM dbo.tblOrderHead
INNER JOIN dbo.tblCustomer ON dbo.tblOrderHead.intOrderNo = #intDocumentNo
Solution
If anyone as stupid as me out there thing the same thing, this is how you solve it:
UPDATE dbo.tblOrderHead
SET dbo.tblOrderHead.intCustomerNo = #intCustomerNo ,
dbo.tblOrderHead.intPaymentCode = dbo.tblCustomer.intPaymentCode,
dbo.tblOrderHead.txtDeliveryCode = dbo.tblCustomer.txtDeliveryCode,
dbo.tblOrderHead.txtRegionCode = dbo.tblCustomer.txtRegionCode,
dbo.tblOrderHead.txtCurrencyCode = dbo.tblCustomer.txtCurrencyCode,
dbo.tblOrderHead.txtLanguageCode = dbo.tblCustomer.txtLanguageCode
FROM dbo.tblOrderHead
INNER JOIN dbo.tblCustomer ON dbo.tblOrderHead.intCustomerNo = dbo.tblCustomer.intCustomerNo
AND dbo.tblOrderHead.intOrderNo = #intDocumentNo
Problem is that, you are not specifying the condition on which the 2 tables tblOrderHead, tblCustomer need to be joined!
you need something like
INNER JOIN dbo.tblCustomer
ON dbo.tblOrderHead.someColumn = dbo.tblCustomer.someColumn
and dbo.tblOrderHead.intOrderNo = #intDocumentNo

Resources